Activemq-.xml
1.加载properties配置参数。下面加载是访问broker的身份信息,即用户名和密码
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
2.配置broker.同时brokerName必须唯一
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="amq-broker" useJmx="true">
3.destination(即queue/topic)的策略
<destinationPolicy></destinationPolicy>
4.限制所有的queue和topic的内存大小;是否开启生产者的流程控制。
<policyEntry queue=">" producerFlowControl="true" memoryLimit="5mb"/>
<policyEntry topic=">" producerFlowControl="true" memoryLimit="5mb">
5.topic类型的分发策略。即一个topic生产的主题,严格按照产生的顺序被消费者接收。并且每个消费者接收的顺序都一样。
<dispatchPolicy>
<strictOrderDispatchPolicy/>
</dispatchPolicy>
strictOrderDispatchPolicy:严格按照产生的顺序被消费;
simpleDispatchPolicy:
roundRobinDispatchPolicy:
priorityNetworkDispatchPolicy:
priorityDispatchPolicy:
6.topic订阅发现的策略。
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy/>
</subscriptionRecoveryPolicy>
7.是否暴露JMX接口。
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
8.broker集群
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:61616)" duplex="true"/>
</networkConnectors>
9.broker中的消息存储方式
<persistenceAdapter>
<kahaDB directory="${activemq.data}/static-broker2/kahadb" />
</persistenceAdapter>
10.activeMQ对服务器的资源分配
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
11.本activeMQ服务对外的协议以及端口
<transportConnectors>
<transportConnector name="openwire" uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
<transportConnector name="ssl" uri="ssl://localhost:61617"/>
<transportConnector name="stomp" uri="stomp://localhost:61613"/>
<transportConnector name="ws" uri="ws://localhost:61614/" />
</transportConnectors>
12.ssl访问上下文
<sslContext>
<sslContext keyStore="file:${activemq.conf}/broker.ks"
keyStorePassword="password" trustStore="file:${activemq.conf}/broker.ts"
trustStorePassword="password"/>
</sslContext>
13.activeMQ关闭时习销毁spring context
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
14.安全身份设置
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="system" password="${activemq.password}"
groups="users,admins"/>
<authenticationUser username="user" password="${guest.password}"
groups="users"/>
<authenticationUser username="guest" password="${guest.password}" groups="guests"/>
</users>
</simpleAuthenticationPlugin>
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
<authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
<authorizationEntry queue="TEST.Q" read="guests" write="guests" />
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
<authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
<authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins>
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/191694.html