activeio-core-3.0.0-incubator.jar
activemq-core-4.1.0-incubator.jar
activemq-ra-4.1.0-incubator.jar
backport-util-concurrent-2.1.jar
commons-logging-1.0.3.jar
derby-10.1.1.0.jar
geronimo-j2ee-management_1.0_spec-1.0.jar
spring-2.0.jar
spring-1.2.6.jar
xbean-spring-2.7.jar
broker-config.xml
META-INF
2.步骤二. 删除多余的spring-1.2.6.jar,由于4.1.0的ra里面包含了2个不同版本的spring会触发一个exception的产生,https://issues.apache.org/activemq/browse/AMQ-1124, 而且为了以后能够使用新的spring schema配置方式,我们这里会删除spring-1.2.6.jar,保留spring-2.0.jar。(最新的snapshot version的ra已经去掉了这个多余的spring-1.2.6.jar).
3.步骤三: 修改META-INF\ra.xml,让JBoss使用broker-config.xml 作为默认的配置文件配置borker. 修改下面的地方
- <config-property-value>config-property-value>
-
改为:
-
- <config-property-value>xbean:broker-config.xmlconfig-property-value>
表示使用broker-config.xml来配置启动ActiveMQ.
4.步骤四: 修改borker-config.xml,默认的borker-config.xml会产生一个错误,无论是我使用的版本还是最后的snapshot版本,默认的borker-config.xml都会让xbean-spring 2.7(snapshot 使用的是2.8)抛出exception.解决的办法如下
将
- <beans xmlns="http://activemq.org/config/1.0">
- <broker useJmx="true" >
改为
- <beans>
- <broker useJmx="true" xmlns="http://activemq.org/config/1.0">
即可
5.步骤五: 将xbean-spring-2.7.jar (或者是2.8) 复制到jboss-4.0.5.GA\server\default\lib下面
三 使用整合完毕的ActiveMQ作为ds绑定到JBoss的JNDI服务。
编写jboss-4.0.5.GA\server\default\depoly\activemq-ds.xml
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE connection-factories
- PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
- "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
-
- <connection-factories>
- <tx-connection-factory>
- <jndi-name>activemq/QueueConnectionFactory</jndi-name>
- <xa-transaction/>
- <track-connection-by-tx/>
- <rar-name>activemq-ra.rar</rar-name>
- <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
- <ServerUrl>tcp://localhost:61616</ServerUrl>
- <min-pool-size>1</min-pool-size>
- <max-pool-size>200</max-pool-size>
- <blocking-timeout-millis>30000</blocking-timeout-millis>
- <idle-timeout-minutes>3</idle-timeout-minutes>
- </tx-connection-factory>
-
- <tx-connection-factory>
- <jndi-name>activemq/TopicConnectionFactory</jndi-name>
- <xa-transaction/>
- <track-connection-by-tx/>
- <rar-name>activemq-ra.rar</rar-name>
- <connection-definition>javax.jms.TopicConnectionFactory</connection-definition>
- <ServerUrl>tcp://localhost:61616</ServerUrl>
- <min-pool-size>1</min-pool-size>
- <max-pool-size>200</max-pool-size>
- <blocking-timeout-millis>30000</blocking-timeout-millis>
- <idle-timeout-minutes>3</idle-timeout-minutes>
- </tx-connection-factory>
-
- <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue">
- <attribute name="JNDIName">activemq/queue/outbound</attribute>
- <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
- <attribute name="Type">javax.jms.Queue</attribute>
- <attribute name="Properties">PhysicalName=queue.outbound</attribute>
- </mbean>
-
- <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.topic:name=inboundTopic">
- <attribute name="JNDIName">activemq/topic/inbound</attribute>
- <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
- <attribute name="Type">javax.jms.Topic</attribute>
- <attribute name="Properties">PhysicalName=topic.inbound</attribute>
- </mbean>
-
- </connection-factories>
启动JBoss.如果看见以下信息就表示ActiveMQ已经成功启动,并且使用上面的ds配置文件成功地将topic/queue绑定到了JNDI服务上。
......
[TransportConnector] Connector tcp://localhost:61616 Started
[NetworkConnector] Network Connector bridge Started
[BrokerService] ActiveMQ JMS Message Broker (localhost, ID:MyNoteBook-2165-1173250880171-1:0) started
......
[ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=activemq/QueueConnectionFactory' to JNDI name 'java:activemq/QueueConnectionFactory'
[ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=activemq/TopicConnectionFactory' to JNDI name 'java:activemq/TopicConnectionFactory'
[AdminObject] Bound admin object 'org.apache.activemq.command.ActiveMQQueue' at 'activemq/queue/outbound'
[AdminObject] Bound admin object 'org.apache.activemq.command.ActiveMQTopic' at 'activemq/topic/inbound
......
四.验证ActiveMQ+JBoss
这里你可以使用简单的jms client连接到broker-config.xml里面的协议连接器上面,默认的是tcp://localhost:61616
在后面我们会在此整合基础上开发Message Driver Bean和使用spring MDP 2种构架 来验证本次ActiveMQ+JBoss的整合。