ActiveMQ的spring配置文件

从官网copy出来,做了部分修改:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <beans xmlns="http://www.springframework.org/schema/beans" 
  3         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4         xmlns:amq="http://activemq.apache.org/schema/core"
  5         xsi:schemaLocation="http://www.springframework.org/schema/beans 
  6         http://www.springframework.org/schema/beans/spring-beans.xsd   
  7         http://activemq.apache.org/schema/core 
  8         http://activemq.apache.org/schema/core/activemq-core.xsd">
  9         
 10 <!-- Allows us to use system properties as variables in this configuration file -->
 11 <!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 12     <property name="locations">
 13         <value>file:${activemq.conf}/credentials.properties</value>
 14     </property>
 15 </bean> -->
 16 <!--
 17     The <broker> element is used to configure the ActiveMQ broker.
 18 -->
 19 <broker xmlns="http://activemq.apache.org/schema/core" brokerName="zhang" dataDirectory=".">
 20     <!--
 21             For better performances use VM cursor and small memory limit.
 22             For more information, see:
 23 
 24             http://activemq.apache.org/message-cursors.html
 25 
 26             Also, if your producer is "hanging", it's probably due to producer flow control.
 27             For more information, see:
 28             http://activemq.apache.org/producer-flow-control.html
 29     -->
 30     <destinationPolicy>
 31         <policyMap>
 32             <policyEntries>
 33                 <policyEntry topic=">" producerFlowControl="true">
 34                     <!-- The constantPendingMessageLimitStrategy is used to prevent
 35                          slow topic consumers to block producers and affect other consumers
 36                          by limiting the number of messages that are retained
 37                          For more information, see:
 38 
 39                          http://activemq.apache.org/slow-consumer-handling.html
 40 
 41                     -->
 42                     <pendingMessageLimitStrategy>
 43                         <constantPendingMessageLimitStrategy limit="1000"/>
 44                     </pendingMessageLimitStrategy>
 45                 </policyEntry>
 46                 <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
 47                 <!-- Use VM cursor for better latency
 48                        For more information, see:
 49 
 50                        http://activemq.apache.org/message-cursors.html
 51 
 52                   <pendingQueuePolicy>
 53                     <vmQueueCursor/>
 54                   </pendingQueuePolicy>
 55                   -->
 56                       <deadLetterStrategy>
 57                           <individualDeadLetterStrategy queuePrefix="TEST"/>
 58                     </deadLetterStrategy>
 59                     <pendingQueuePolicy>
 60                         <storeCursor/>
 61                     </pendingQueuePolicy>
 62                  </policyEntry>
 63             </policyEntries>
 64         </policyMap>
 65     </destinationPolicy>
 66     <!--
 67         The managementContext is used to configure how ActiveMQ is exposed in
 68         JMX. By default, ActiveMQ uses the MBean server that is started by
 69         the JVM. For more information, see:
 70 
 71         http://activemq.apache.org/jmx.html
 72     -->
 73     <managementContext>
 74         <managementContext createConnector="false"/>
 75     </managementContext>
 76     <!--
 77         Configure message persistence for the broker. The default persistence
 78         mechanism is the KahaDB store (identified by the kahaDB tag).
 79         For more information, see:
 80 
 81         http://activemq.apache.org/persistence.html
 82     -->
 83     <persistenceAdapter>
 84         <kahaDB directory="kahadb"/>
 85     </persistenceAdapter>
 86     <!--
 87     The systemUsage controls the maximum amount of space the broker will
 88     use before slowing down producers. For more information, see:
 89     http://activemq.apache.org/producer-flow-control.html
 90     If using ActiveMQ embedded - the following limits could safely be used:
 91 
 92     <systemUsage>
 93         <systemUsage>
 94             <memoryUsage>
 95             
 96                 <memoryUsage limit="20 mb"/>
 97             </memoryUsage>
 98             <storeUsage>
 99                 <storeUsage limit="1 gb"/>
100             </storeUsage>
101             <tempUsage>
102                 <tempUsage limit="100 mb"/>
103             </tempUsage>
104         </systemUsage>
105     </systemUsage>
106     -->
107     <systemUsage>
108         <systemUsage>
109             <memoryUsage>
110                 <memoryUsage limit="1 mb"/>
111             </memoryUsage>
112             <storeUsage>
113                 <storeUsage limit="32 mb"/>
114             </storeUsage>
115             <tempUsage>
116                 <tempUsage limit="32 mb"/>
117             </tempUsage>
118         </systemUsage>
119     </systemUsage>
120     <!--
121         The transport connectors expose ActiveMQ over a given protocol to
122         clients and other brokers. For more information, see:
123 
124         http://activemq.apache.org/configuring-transports.html
125     -->
126     <transportConnectors>
127     <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
128         <transportConnector name="openwire"
129         uri="tcp://0.0.0.0:61616?maximumConnections=1000"/>
130         <transportConnector name="amqp"
131         uri="amqp://0.0.0.0:5672?maximumConnections=1000"/>
132     </transportConnectors>
133     <!-- destroy the spring context on shutdown to stop jetty -->
134     <shutdownHooks>
135         <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook"/>
136     </shutdownHooks>
137 </broker>
138 <!--
139         Enable web consoles, REST and Ajax APIs and demos
140 
141         Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
142 -->
143 <!-- <import resource="jetty.xml"/> -->
144 </beans>

 关于通配符的说明(http://activemq.apache.org/wildcards.html):

. is used to separate names in a path
* is used to match any name in a path
> is used to recursively match any destination starting from this name

原文地址:https://www.cnblogs.com/allenwas3/p/8653440.html