XML配置文件
n 由端口通道和wire格式组成的端口连接器的说明:增加一个链接页说明端口连接器是如何配置的、如何使用的。
n 由网络通道和发现组成的网络连接器说明:增加一个链接页面说明网络连接器是如何配置和使用的。
n 发现代理说明:增加一个链接页面说明发现代理如何配置和使用的。
n 持久化提供者和定位说明:增加一个链接页面说明持久化提供者如何配置和使用的。
n 自定义消息容器(例如缓存的最后一个图形)。
我们使用XBean来执行XML配置。
关于XML配置的详细信息请查看XML参考。
注意代理名和URI:确保你没有使用一些奇怪的字符来定义代理名称。当他们被转换为URI时,会不允许使用下划线之类的字符。
示例:
缺省的ActiveMQ配置:当前缺省的配置
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/corehttp://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in thisconfiguration file -->
<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.base}/conf/credentials.properties</value>
</property>
</bean>
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core"brokerName="localhost"dataDirectory="${activemq.base}/data">
<!--
Forbetter performances use VM cursor and small memory limit.
Formore information, see:
http://activemq.apache.org/message-cursors.html
Also, if your producer is "hanging", it's probably due toproducer flow control.
For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntrytopic=">" producerFlowControl="true"memoryLimit="1mb">
<pendingSubscriberPolicy>
<vmCursor />
</pendingSubscriberPolicy>
</policyEntry>
<policyEntryqueue=">" producerFlowControl="true"memoryLimit="1mb">
<!-- Use VM cursor forbetter latency
For more information,see:
http://activemq.apache.org/message-cursors.html
<pendingQueuePolicy>
<vmQueueCursor/>
</pendingQueuePolicy>
-->
</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
-->
<persistenceAdapter>
<kahaDB directory="${activemq.base}/data/kahadb"/>
</persistenceAdapter>
<!--
The systemUsage controls the maximum amount of space the broker will
use before slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsagelimit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsagelimit="1 gb"/>
</storeUsage>
<tempUsage>
<tempUsagelimit="100 mb"/>
</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
-->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>
</broker>
<!--
Enable web consoles, REST and Ajax APIs and demos
Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
<import resource="jetty.xml"/>
</beans>
可执行文件的发行版有一个activemq脚本允许你从命令行来运行来运行消息代理,此代理作为一个独立的进程,在此之前你只需配置PATH的$ACTIVEMQ_HOME/bin目录。
配置嵌入式代理
你可以使用XML文件来配置嵌入式代理。例如使用JNDI配置原理,查看BrokerXmlConfigFromJNDITest这个示例。
或者通过java代码来显式的配置嵌入式代理,请查阅BrokerXmlConfigTest示例。
用户提交配置
我们有一个页面允许用户提交来提交配置的信息。
n 用户提交配置
背景
ActiveMQ有如此多的策略模板插件提供给端口、wire格式、持久化和其他的许多事情,我们希望保持配置格式开放,以便你可以配置和任何方向的扩展。
所以我们使用SpringXml配置文件格式,它允许beans/POJOs一起工作和配置。可是Spring的XML通常很长,以至我们实现ActiveMQ扩展到Spring XML中,你可以只知道最常用的,标准的ActiveMQ的配置(例如连接器、wire格式、服务器端口和持久化的标志),而不需要求助于如何使用Spring的方法(例如bean、property标志)。
如何使用和访问XSD/DTD的XML文件的文档请查看 XML参考。