http://tomee.apache.org/jms-resources-and-mdb-container.html
http://activemq.apache.org/xml-configuration.html
http://activemq.apache.org/persistence.html
http://activemq.apache.org/configuring-transports.html
文件位置
[tomee]/conf/tomee.xml
[tomee]/conf/activemq.xml
使用配置文件(activemq.xml)可以简化配置(../conf/activemq.xml 可以指定全路径 ps:是相对于启动tomcat的命令执行位置的相对路径,例如:[tomee]/bin 下执行starup.bat, 对应为../conf/activemq.xlm
[tomee] 下执行bin\startup.bat,对应为conf/activemq.xml)
<tomee> <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter"> BrokerXmlConfig = xbean:file:../conf/activemq.xml ServerUrl = tcp://someHostName:61616 </Resource> <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory"> ResourceAdapter = MyJmsResourceAdapter </Resource> <Container id="MyJmsMdbContainer" ctype="MESSAGE"> ResourceAdapter = MyJmsResourceAdapter </Container> <Resource id="FooQueue" type="javax.jms.Queue"/> <Resource id="BarTopic" type="javax.jms.Topic"/> </tomee>
AMQ 5.x (../derby 可以指定全路径,自动创建)
<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/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <broker useJmx="true" xmlns="http://activemq.apache.org/schema/core"> <networkConnectors> <!-- <networkConnector uri="multicast://default?initialReconnectDelay=100" /> <networkConnector uri="static://(tcp://localhost:61616)" /> --> </networkConnectors> <persistenceFactory> <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="../derby" /> <!-- To use a different dataSource, use the following syntax : --> <!-- <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="${basedir}/activemq-data" dataSource="#mysql-ds"/> --> </persistenceFactory> <transportConnectors> <transportConnector uri="tcp://localhost:61616" /> </transportConnectors> </broker> <!-- MySql DataSource Sample Setup --> <!-- <bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/> <property name="username" value="activemq"/> <property name="password" value="activemq"/> <property name="poolPreparedStatements" value="true"/> </bean> --> </beans>
所需的 jar 包
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-spring</artifactId> <version>5.14.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>artemis-journal</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activeio-core</artifactId> <version>3.1.4</version> </dependency> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.12.1.1</version> </dependency>
ps: localhost 只试用于本机remote client
如需不同机器之间remote client,需指定具体外网ip