<networkConnectors>
<networkConnector uri="masterslave:(tcp://host1:61616,tcp://host2:61616,tcp://..)"/>
</networkConnectors>
<networkConnectors>
<networkConnector uri="static:(tcp://host1:61616,tcp://host2:61617,tcp://..)"/>
</networkConnectors>
表示当前local broker与remote broker(61616/61617)建立的单向网络连接。即local broker可以将消息传递给remote broker,但反过来就不行。duplex="true" 属性配置可以开启双向通信。
<networkConnectors>
<networkConnector uri="multicast://default"/>
</networkConnectors>
<transportConnector uri="tcp://localhost:0" discoveryUri="multicast://default"/>
组播发现会自动发现同网络中的broker并进行连接通信。注意:必须是同网络中。
在实际的配置很少这样配置,因为无法保证哪些brokers建立了连接。对于master-slave配置也不是很好。
<dynamicallyIncludedDestinations>
<queue physicalName="include.test.foo"/>
<topic physicalName="include.test.bar"/>
</dynamicallyIncludedDestinations>
当networkConnector中连接的broker有customers时,那么对应的destinations才会传递到对应的broker。否则,不传递。这中方式对于point-to-point的方式就比较合适。
<staticallyIncludedDestinations>
<queue physicalName="always.include.queue"/>
<topic physicalName="always.include.topic"/>
</staticallyIncludedDestinations>
不管networkConnector中连接的broker有无customers,都会讲消息发送到每个broker去。这种方式比较适合topic的消息方式。
<excludedDestinations>
<queue physicalName="exclude.test.foo"/>
<topic physicalName="exclude.test.bar"/>
</excludedDestinations>
networkConnector中指定某些detination不会发送到remote brokers.
uri="static:(tcp://host1:61616,tcp://host2:61616)?maxReconnectDelay=5000&useExponentialBackOff=false"
initialReconnectDelay:重连的时间间隔。
maxReconnectDelay:最大重连时间。即initialReconnectDelay次数
useExponentialBackOff:一次连接失败,后面的重连时间是否依次递增。
backOffMultiplier:当useExponentialBackOff=true,重连时间的间隔的倍数,即initialReconnectDelaybackOffMultiplier
name:连接名称,多个时必须唯一。
dynamicOnly:
decreaseNetworkConsumerPriority:
networkTTL:
messageTTL:
consumerTTL:
conduitSubscriptions:管道订阅。即一个broker有多个customers,也只会认为是一个customer.
excludedDestinations:
dynamicallyIncludedDestinations:
useVirtualDestSubs:
staticallyIncludedDestinations:
duplex:是否开启双工通信
prefetchSize:
suppressDuplicateQueueSubscriptions:
bridgeTempDestinations:
alwaysSyncSend:
staticBridge:静态连接桥。与staticallyIncludedDestinations联合使用
userName:networkConnector连接用户名
password:networkConnector连接密码
broker-master
<networkConnectors>
<networkConnector name="connector_master_slave" uri="static:(tcp://localhost:61618,tcp://localhost:61619)"
userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-slave01
<networkConnectors>
<networkConnector name="connector_master_slave" uri="static:(tcp://localhost:61617,tcp://localhost:61619)" userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61618?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-slave02
<networkConnectors>
<networkConnector name="connector_master_slave"
uri="static:(tcp://localhost:61617,tcp://localhost:61618)" userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
broker-cluster01
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:61621)" duplex="false" name="connector_broker_normal" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">" />
<topic physicalName=">" />
</dynamicallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61620?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-cluster02
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:61620)" duplex="false" name="connector_broker_normal" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">" />
<topic physicalName=">" />
</dynamicallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire"uri="tcp://0.0.0.0:61621?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
brokers的安全配置
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="admins"/>
</users>
</simpleAuthenticationPlugin>
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic=">" read="admins" write="admins" admin="admins"/>
</authorizationEntries>
<tempDestinationAuthorizationEntry>
<tempDestinationAuthorizationEntry read="admins" write="admins" admin="admins"/>
</tempDestinationAuthorizationEntry>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins>
参考文档:
http://activemq.apache.org/networks-of-brokers.html
http://shift-alt-ctrl.iteye.com/blog/2070531
https://www.cnblogs.com/shihaiming/p/6018916.html
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。