mwjhw216 发表于 2017-1-13 07:40:35

jboss-4.2.3.GA++apache-activemq-5.1.0整合

一.整合需要的环境.
            jdk1.6
            jboss-4.2.3.GA
            apache-activemq-5.1.0(直接解压就可以用。)
二.整合步骤
            1. 解压activemq-rar-5.1.0.rar到 jboss-4.2.3.GA
\server\default\deploy\activemq-ra.rar (activemq-rar-5.1.0.rar在apache-activemq-5.1.0\lib\optional下面找到)。
            2.xbean-spring-3.3.jar剪贴到jboss-4.2.3.GA\server\default\lib下。
            3.修改META-INF\ra.xml,让JBoss使用broker-config.xml 作为默认的配置文件配置borker. 修改下面的地方
<config-property-value>config-property-value>               
<!--<config-property-value>xbean:broker-config.xml</config-property-value>-->   
     改为:
<!-- <config-property-value></config-property-value> -->   
<config-property-value>xbean:broker-config.xml<config-property-value>   

    表示使用broker-config.xml来配置启动ActiveMQ.
      4.修改borker-config.xml,默认的borker-config.xml会产生一个错误,无论是我使用的版本还是最后的snapshot版本,默认的borker-config.xml都会让xbean-spring 3.3抛出exception.解决的办法如下
将         
<beans xmlns="http://activemq.org/config/1.0">   
          <broker useJmx="true" >   
      
   改为

<beans>   
<broker useJmx="true" xmlns="http://activemq.org/config/1.0">
三 使用整合完毕的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>vm://localhost</ServerUrl>
      <!--
      <UserName>sa</UserName>
      <Password></Password>
      -->
      <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>vm://localhost</ServerUrl>
      <!--
      <UserName>sa</UserName>
      <Password></Password>
      -->
      <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>


然后在将spring-context.jar,spring-core.jar,spring-beans.jar添加到
activemq-ra.rar下。
四。启动jboss如果出现:
17:03:27,421 INFO Using Persistence Adapter: JournalPersistenceAdapator(JDBCPersistenceAdaptor(org.apache.derby.jdbc.EmbeddedDataSource@5971c3))
17:03:27,421 INFO ActiveMQ 5.1.0 JMS Message Broker (bruce.broker1) is starting
17:03:27,421 INFO For help or more information please see: http://activemq.apache.org/
17:03:27,484 INFO JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi
17:03:28,421 INFO Database driver recognized:
17:03:29,296 INFO Attempting to acquire the exclusive lock to become the Master broker
17:03:29,312 INFO Becoming the master on dataSource: org.apache.derby.jdbc.EmbeddedDataSource@5971c3
17:03:29,343 INFO Journal Recovery Started from: Active Journal: using 5 x 20.0 Megs at: D:\jboss-4.2.3.GA\data\journal就代表你成功了。
如果在出现:
17:06:05,984 INFO Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@b36022: defining beans ; root of factory hierarchy
17:06:06,125 INFO Using Persistence Adapter: JournalPersistenceAdapator(JDBCPersistenceAdaptor(org.apache.derby.jdbc.EmbeddedDataSource@de6570))
17:06:06,140 INFO ActiveMQ 5.1.0 JMS Message Broker (bruce.broker1) is starting
17:06:06,140 INFO For help or more information please see: http://activemq.apache.org/
17:06:06,140 WARN Failed to start jmx connector: Cannot bind to URL : javax.naming.CommunicationException
解决方法:
在broker-config.xml中添加:
<managementContext>
<managementContextcreateConnector="true" connectorPort="1199"/>
</managementContext>
然后启动jboss。
页: [1]
查看完整版本: jboss-4.2.3.GA++apache-activemq-5.1.0整合