Created
July 27, 2015 17:14
-
-
Save seratch/02d4618cb423a9f498b4 to your computer and use it in GitHub Desktop.
STOMP virtual host examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<!-- | |
For more information on how configure this file please reference: | |
http://activemq.apache.org/apollo/versions/1.7.1/website/documentation/user-manual.html | |
--> | |
<broker xmlns="http://activemq.apache.org/schema/activemq/apollo"> | |
<log_category console="console" security="security" connection="connection" audit="audit"/> | |
<authentication domain="apollo"/> | |
<!-- Give admins full access --> | |
<access_rule allow="admins" action="*"/> | |
<access_rule allow="*" action="connect" kind="connector"/> | |
<virtual_host id="client1"> | |
<host_name>client1</host_name> | |
<access_rule allow="users" action="connect create destroy send receive consume"/> | |
<leveldb_store directory="${apollo.base}/data/1"/> | |
</virtual_host> | |
<virtual_host id="client2"> | |
<host_name>client2</host_name> | |
<access_rule allow="users" action="connect create destroy send receive consume"/> | |
<leveldb_store directory="${apollo.base}/data/2"/> | |
</virtual_host> | |
<web_admin bind="http://127.0.0.1:61680"/> | |
<web_admin bind="https://127.0.0.1:61681"/> | |
<connector id="tcp" bind="tcp://0.0.0.0:61613" connection_limit="2000"/> | |
<connector id="tls" bind="tls://0.0.0.0:61614" connection_limit="2000"/> | |
<connector id="ws" bind="ws://0.0.0.0:61623" connection_limit="2000"/> | |
<connector id="wss" bind="wss://0.0.0.0:61624" connection_limit="2000"/> | |
<key_storage file="${apollo.base}/etc/keystore" password="password" key_password="password"/> | |
</broker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stomp' | |
base_settings = { | |
hosts: [ | |
{ | |
login: 'app_a', | |
passcode: 'password', | |
host: 'localhost', | |
port: 61613, | |
} | |
] | |
} | |
client1_settings = base_settings.clone | |
client1_settings[:connect_headers] = { | |
'accept-version' => '1.2', | |
'host' => 'client1' | |
} | |
client1 = Stomp::Client.new(client1_settings) | |
app_b_settings = { | |
hosts: [ | |
{ | |
login: 'app_b', | |
passcode: 'password', | |
host: 'localhost', | |
port: 61613, | |
} | |
], | |
connect_headers: { | |
'accept-version' => '1.2', | |
'host' => 'client1' | |
} | |
} | |
client12 = Stomp::Client.new(app_b_settings) | |
client2_settings = base_settings.clone | |
client2_settings[:connect_headers] = { | |
'accept-version' => '1.2', | |
'host' => 'client2' | |
} | |
client2 = Stomp::Client.new(client2_settings) | |
client1_publisher = Stomp::Client.new(client1_settings) | |
client2_publisher = Stomp::Client.new(client2_settings) | |
client1.subscribe("/topic/mine") { |msg| puts "client 1 got #{msg.body}" } | |
client12.subscribe("/topic/mine") { |msg| puts "client 1/B got #{msg.body}" } | |
client2.subscribe("/topic/mine") { |msg| puts "client 2 got #{msg.body}" } | |
3.times do |_| | |
client1_publisher.publish('/topic/mine', 'client 1 msg') | |
client2_publisher.publish('/topic/mine', 'client 2 msg') | |
end | |
sleep 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'stomp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## --------------------------------------------------------------------------- | |
## Licensed to the Apache Software Foundation (ASF) under one or more | |
## contributor license agreements. See the NOTICE file distributed with | |
## this work for additional information regarding copyright ownership. | |
## The ASF licenses this file to You under the Apache License, Version 2.0 | |
## (the "License"); you may not use this file except in compliance with | |
## the License. You may obtain a copy of the License at | |
## | |
## http://www.apache.org/licenses/LICENSE-2.0 | |
## | |
## Unless required by applicable law or agreed to in writing, software | |
## distributed under the License is distributed on an "AS IS" BASIS, | |
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
## See the License for the specific language governing permissions and | |
## limitations under the License. | |
## --------------------------------------------------------------------------- | |
# | |
# Allows you to place multiple users in a group. | |
# Example: | |
# | |
# power_users=admin|chirino | |
# | |
admins=admin | |
users=app_a|app_b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/apollo-broker run | |
_____ .__ .__ | |
/ _ \ ______ ____ | | | | ____ | |
/ /_\ \\____ \ / _ \| | | | / _ \ | |
/ | \ |_> > <_> ) |_| |_( <_> ) | |
\____|__ / __/ \____/|____/____/\____/ | |
\/|__| Apache Apollo (1.7.1) | |
Loading configuration file '/Users/seratch/tmp/hello-apollo/etc/apollo.xml'. | |
INFO | OS : Mac OS X 10.10.4 | |
INFO | JVM : Java HotSpot(TM) 64-Bit Server VM 1.8.0 (Oracle Corporation) | |
INFO | Apollo : 1.7.1 (at: /usr/local/Cellar/apollo/1.7.1/libexec) | |
INFO | OS is restricting the open file limit to: 6250 | |
WARN | Please increase the process file limit using 'ulimit -n 8500' or configure lower connection limits on the broker connectors. | |
INFO | Starting store: leveldb store at /Users/seratch/tmp/hello-apollo/data/2 | |
INFO | Starting store: leveldb store at /Users/seratch/tmp/hello-apollo/data/1 | |
INFO | Accepting connections at: tcp://0.0.0.0:61613 | |
INFO | Accepting connections at: tls://0.0.0.0:61614 | |
INFO | Accepting connections at: ws://0.0.0.0:61623/ | |
INFO | Accepting connections at: wss://0.0.0.0:61624/ | |
INFO | Administration interface available at: https://127.0.0.1:61681/ | |
INFO | Administration interface available at: http://127.0.0.1:61680/ | |
$ ruby example.rb | |
client 1/B got client 1 msg | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 1 got client 1 msg | |
$ ruby example.rb | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 1/B got client 1 msg | |
client 2 got client 2 msg | |
client 1 got client 1 msg | |
$ ruby example.rb | |
client 1/B got client 1 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 2 got client 2 msg | |
client 1 got client 1 msg | |
$ ruby example.rb | |
client 1 got client 1 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 1/B got client 1 msg | |
client 1 got client 1 msg | |
client 2 got client 2 msg | |
client 1/B got client 1 msg | |
client 2 got client 2 msg | |
client 2 got client 2 msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## --------------------------------------------------------------------------- | |
## Licensed to the Apache Software Foundation (ASF) under one or more | |
## contributor license agreements. See the NOTICE file distributed with | |
## this work for additional information regarding copyright ownership. | |
## The ASF licenses this file to You under the Apache License, Version 2.0 | |
## (the "License"); you may not use this file except in compliance with | |
## the License. You may obtain a copy of the License at | |
## | |
## http://www.apache.org/licenses/LICENSE-2.0 | |
## | |
## Unless required by applicable law or agreed to in writing, software | |
## distributed under the License is distributed on an "AS IS" BASIS, | |
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
## See the License for the specific language governing permissions and | |
## limitations under the License. | |
## --------------------------------------------------------------------------- | |
# | |
# The list of users that can login. This file supports both plain text or | |
# encrypted passwords. Here is an example what an encrypted password | |
# would look like: | |
# | |
# admin=ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL) | |
# | |
admin=password | |
app_a=password | |
app_b=password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment