<!-- START SNIPPET: example --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> <!-- Allows us to use system properties as variables in this configuration file --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>file:${activemq.conf}/credentials.properties</value> </property> </bean> <!-- Allows log searching in hawtio console --> <bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop"> </bean> <!-- The <broker> element is used to configure the ActiveMQ broker. -->
<!--borker 的配置:--> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"> <!--目的地的一些策略--> <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" > <!-- The constantPendingMessageLimitStrategy is used to prevent slow topic consumers to block producers and affect other consumers by limiting the number of messages that are retained For more information, see: http://activemq.apache.org/slow-consumer-handling.html --> <pendingMessageLimitStrategy> <constantPendingMessageLimitStrategy limit="1000"/> </pendingMessageLimitStrategy> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> <!-- The managementContext is used to configure how ActiveMQ is exposed in JMX. By default, ActiveMQ uses the MBean server that is started by the JVM. For more information, see: http://activemq.apache.org/jmx.html 管理--> <managementContext> <managementContext createConnector="false"/> </managementContext> <!-- Configure message persistence for the broker. The default persistence mechanism is the KahaDB store (identified by the kahaDB tag). For more information, see: http://activemq.apache.org/persistence.html 消息存儲持久化的方案
①ActiveMQ不僅支持持久化和非持久化兩種方式,還支持,消息的恢復方式
②ActiveMQ提供了一個插件式的消息存儲,類似於消息的多點傳播,主要實現如下幾種
③AMQ消息存儲-基於文件的存儲方式,是以前的默認消息存儲
④KahaDB消息存儲-提供了容量的提升和恢復能力,是現在默認的存儲方式
⑤JDBC消息存儲-消息基於JDBC存儲的
⑥Memory消息存儲-基於內存的消息存儲
--> <persistenceAdapter> <kahaDB directory="${activemq.data}/kahadb"/> </persistenceAdapter> <!-- The systemUsage controls the maximum amount of space the broker will use before disabling caching and/or slowing down producers. For more information, see: http://activemq.apache.org/producer-flow-control.html 磁盤的控制 --> <systemUsage> <systemUsage> <memoryUsage> <memoryUsage percentOfJvmHeap="70" /> </memoryUsage> <storeUsage> <storeUsage limit="100 gb"/> </storeUsage> <tempUsage> <tempUsage limit="50 gb"/> </tempUsage> </systemUsage> </systemUsage> <!-- The transport connectors expose ActiveMQ over a given protocol to clients and other brokers. For more information, see: http://activemq.apache.org/configuring-transports.html 指從客戶端如何連接到broker上去 --> <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<!--①openwire 指,tcp,,,stomp,mqtt這些都是協議,
②常見的協議:TCP,NIO,UDP,SSL,HTTP(s),VM
③VM:如果客戶端和broker在一個虛擬機內的話,通過VM協議通訊在VM內通訊,從而減少網絡傳輸的開銷
④tcp://0.0.0.0:61616:這里的端口號,可以改,改了之后客戶端連接的也要改
⑤http://activemq.apache.org/configuring-version-5-transports.html
⑥NIO:可能有大量的Client去鏈接到Broker上,一般情況下,大量的Client去連接到Broker是被操作系統的線程數所限制的,因此NIO的實現比TCP需要更少的線程去運行,所以建議使用NIO協議
⑦NIO:可能對於Broker有一個很遲鈍的網絡傳輸,NIO比TCP提供更好的性能
⑧NIO:NIO連接的URI形式:nio://hostname:port?key=value
⑨Transport Connector配置示例:<transportConnector name="nio" uri="nio:localhost:61618?trace=true"/>
⑩
⑪⑫
--> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> </transportConnectors> <!-- destroy the spring context on shutdown to stop jetty --> <shutdownHooks> <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /> </shutdownHooks> </broker> <!-- Enable web consoles, REST and Ajax APIs and demos The web consoles requires by default login, you can disable this in the jetty.xml file Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details --> <import resource="jetty.xml"/> </beans> <!-- END SNIPPET: example -->