ActiveMQ配置文件

<!-- 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&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;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 -->
原文地址:https://www.cnblogs.com/an5211/p/7156099.html