`
snowzjq
  • 浏览: 3638 次
  • 性别: Icon_minigender_2
  • 来自: 福州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

ActiveMQ5.2.0集成到JBoss4.X

阅读更多
1、在JBoss的部署目录下建立activemq-ra.rar目录(注意这是一个目录)

2、在ActiveMQ5.2.0的目录X:\apache-activemq-5.2.0\lib\optional下找到activemq-rar-     5.2.0.rar文件,将其全部内容解压缩到第一步建立的目录

3、上面的解压的后,找到META-INF\ra.xml文件,按照下面进行修改

<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>

4、配置jboss4.2.3.GA集成ActiveMQ5.2.0的数据源,文件名activemq-ds.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=&apos;activemq-ra.rar&apos;</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=&apos;activemq-ra.rar&apos;</depends>  
      <attribute name="Type">javax.jms.Topic</attribute>  
      <attribute name="Properties">PhysicalName=topic.inbound</attribute>  
   </mbean>  
</connection-factories>  

将此文件复制到jboss的部署目录

5、将X:\apache-activemq-5.2.0\lib\optional下的的以spring-开头的文件、xbean-spring-3.4.jar文件、commons-dbcp-1.2.jar、commons-pool-1.4.jar复制到

x:\jboss-4.2.3.GA\server\default\lib中

6、测试运行,注意查看jboss控制台,有类似以下内容

12:17:21,538 INFO  [RARDeployment] Required license terms exist, view META-INF/r
a.xml in .../deploy/activemq-ra.rar/
12:17:21,677 INFO  [ResourceXmlApplicationContext] Refreshing org.apache.xbean.s
pring.context.ResourceXmlApplicationContext@2d4c7e: display name [org.apache.xbe
an.spring.context.ResourceXmlApplicationContext@2d4c7e]; startup date [Mon Jan 1
9 12:17:21 CST 2009]; root of context hierarchy
12:17:21,771 INFO  [XBeanXmlBeanDefinitionReader] Loading XML bean definitions f
rom class path resource [broker-config.xml]
12:17:22,008 INFO  [ResourceXmlApplicationContext] Bean factory for application
context [org.apache.xbean.spring.context.ResourceXmlApplicationContext@2d4c7e]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@17777a1
12:17:22,024 INFO  [DefaultListableBeanFactory] Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@17777a1: de
fining beans [org.apache.activemq.xbean.XBeanBrokerService#0]; root of factory h
ierarchy
12:17:23,284 INFO  [BrokerService] Using Persistence Adapter: JournalPersistence
Adapator(JDBCPersistenceAdaptor(org.apache.derby.jdbc.EmbeddedDataSource@8d539f)
)

7、配置消息持久化数据库,使用以下内容替换broker-config.xml文件内容,注意配置数据库连接参数,以及将jdbc驱动库文件拷贝到jboss/server/default/lib目录中

    <!--
        Licensed to the Apache Software Foundation (ASF) under one or more
        contributor license agreements. See the NOTICE file distributed with
        this work for additional information regarding copyright ownership.
        The ASF licenses this file to You under the Apache License, Version
        2.0 (the "License"); you may not use this file except in compliance
        with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by
        applicable law or agreed to in writing, software distributed under the
        License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
        CONDITIONS OF ANY KIND, either express or implied. See the License for
        the specific language governing permissions and limitations under the
        License.
    -->
    <!-- START SNIPPET: example -->
<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
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.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.base}/conf/credentials.properties </value>
        </property> </bean>
    -->

    <broker xmlns="http://activemq.apache.org/schema/core"
        brokerName="localhost" dataDirectory="../data">

        <!--
            Destination specific policies using destination names or wildcards
        -->
        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">" memoryLimit="5mb" />
                    <policyEntry topic=">" memoryLimit="5mb">
                        <!--
                            you can add other policies too such as these <dispatchPolicy>
                            <strictOrderDispatchPolicy/> </dispatchPolicy>
                            <subscriptionRecoveryPolicy>
                            <lastImageSubscriptionRecoveryPolicy/>
                            </subscriptionRecoveryPolicy>
                        -->
                    </policyEntry>
                </policyEntries>
            </policyMap>
        </destinationPolicy>

        <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
        <managementContext>
            <managementContext createConnector="false" />
        </managementContext>

        <transportConnectors>
            <!--
                prefixing a connector with discovery: causes the connector to be
                advertiesed over rendezvous
            -->
            <transportConnector uri="tcp://localhost:61616"
                discoveryUri="multicast://default" />
        </transportConnectors>

        <networkConnectors>
            <!-- by default just auto discover the other brokers -->
            <networkConnector uri="multicast://default" />
            <!--
                <networkConnector
                uri="static://(tcp://host1:61616,tcp://host2:61616)"/>
            -->
        </networkConnectors>

        <!--
            <persistenceAdapter> <amqPersistenceAdapter syncOnWrite="false"
            directory="../data" maxFileLength="20 mb" /> </persistenceAdapter>
        -->
        <!--
            Use the following if you wish to configure the journal with JDBC
        -->
        <!--
            <persistenceAdapter> <journaledJDBC
            dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
            </persistenceAdapter>
        -->

        <!-- Or if you want to use pure JDBC without a journal -->
        <!---->
        <persistenceAdapter>
            <jdbcPersistenceAdapter dataSource="#mysql-ds" />
        </persistenceAdapter>

        <!--
            <sslContext> <sslContext
            keyStore="file:${activemq.base}/conf/broker.ks"
            keyStorePassword="password"
            trustStore="file:${activemq.base}/conf/broker.ts"
            trustStorePassword="password"/> </sslContext>
        -->

        <!--
            The maximum about of space the broker will use before slowing down
            producers
        -->
        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="20 mb" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="1 gb" name="foo" />
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="100 mb" />
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <!--
            The transport connectors ActiveMQ will listen to
            <transportConnectors> <transportConnector name="openwire"
            uri="tcp://localhost:61616" discoveryUri="multicast://default" />
            <transportConnector name="ssl" uri="ssl://localhost:61617" />
            <transportConnector name="stomp" uri="stomp://localhost:61613" />
            <transportConnector name="xmpp" uri="xmpp://localhost:61222" />
            </transportConnectors>
        -->
    </broker>

    <!--
        ** Lets deploy some Enterprise Integration Patterns inside the
        ActiveMQ Message Broker ** For more details see ** **
http://activemq.apache.org/enterprise-integration-patterns.html
    -->
    <!--
        <camelContext id="camel"
        xmlns="http://activemq.apache.org/camel/schema/spring">

        <package>org.foo.bar</package> <route> <from uri="activemq:example.A"
        /> <to uri="activemq:example.B" /> </route> </camelContext>
    -->
    <!--
        ** Lets configure some Camel endpoints ** **
http://activemq.apache.org/camel/components.html
    -->

    <!--
        configure the camel activemq component to use the current broker <bean
        id="activemq"
        class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory"> <bean
        class="org.apache.activemq.ActiveMQConnectionFactory"> <property
        name="brokerURL"
        value="vm://localhost?create=false&amp;waitForStart=10000" />
        <property name="userName" value="${activemq.username}" /> <property
        name="password" value="${activemq.password}" /> </bean> </property>
        </bean>
    -->

    <!--
        Uncomment to create a command agent to respond to message based admin
        commands on the ActiveMQ.Agent topic
    -->
    <!--
        <commandAgent xmlns="http://activemq.apache.org/schema/core"
        brokerUrl="vm://localhost" username="${activemq.username}"
        password="${activemq.password}"/>
    -->

    <!--
        An embedded servlet engine for serving up the Admin console <jetty
        xmlns="http://mortbay.com/schemas/jetty/1.0"> <connectors>
        <nioConnector port="8161" /> </connectors> <handlers> <webAppContext
        contextPath="/admin" resourceBase="${activemq.base}/webapps/admin"
        logUrlOnStart="true" /> <webAppContext contextPath="/demo"
        resourceBase="${activemq.base}/webapps/demo" logUrlOnStart="true" />
        <webAppContext contextPath="/fileserver"
        resourceBase="${activemq.base}/webapps/fileserver"
        logUrlOnStart="true" /> </handlers> </jetty>
    -->
    <!--
        This xbean configuration file supports all the standard spring xml
        configuration options
    -->

    <!-- Postgres DataSource Sample Setup -->
    <!--
        <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
        <property name="serverName" value="localhost"/> <property
        name="databaseName" value="activemq"/> <property name="portNumber"
        value="0"/> <property name="user" value="activemq"/> <property
        name="password" value="activemq"/> <property name="dataSourceName"
        value="postgres"/> <property name="initialConnections" value="1"/>
        <property name="maxConnections" value="10"/> </bean>
    -->

    <!-- MySql DataSource Sample Setup -->
    <!---->
    <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url"
            value="jdbc:mysql://localhost:3306/mydb?characterEncoding=utf-8&amp;relaxAutoCommit=true" />
        <property name="username" value="root" />
        <property name="password" value="root" />
        <property name="maxActive" value="200" />
        <property name="poolPreparedStatements" value="true" />
    </bean>

    <!-- Oracle DataSource Sample Setup -->
    <!--
        <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close"> <property name="driverClassName"
        value="oracle.jdbc.driver.OracleDriver"/> <property name="url"
        value="jdbc:oracle:thin:@localhost:1521:AMQDB"/> <property
        name="username" value="scott"/> <property name="password"
        value="tiger"/> <property name="maxActive" value="200"/> <property
        name="poolPreparedStatements" value="true"/> </bean>
    -->

    <!-- Embedded Derby DataSource Sample Setup -->
    <!--
        <bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
        <property name="databaseName" value="derbydb"/> <property
        name="createDatabase" value="create"/> </bean>
    -->

</beans>
    <!-- END SNIPPET: example -->
分享到:
评论

相关推荐

    apache-activemq-5.2.0.zip_activeMq 5.2.0_apache mq

    - conf目录:存放配置文件,如activemq.xml,用于配置broker和各种设置。 - lib目录:包含运行ActiveMQ所需的库文件。 - docs目录:包含API文档和其他技术文档。 - examples目录:包含了一些示例代码,帮助开发者...

    activemq-web-5.2.0.jar.zip

    《ActiveMQ Web 5.2.0:Java Web 服务集成与消息传递详解》 Apache ActiveMQ 是一个开源的消息中间件,它遵循 JMS(Java Message Service)规范,提供了高效、可靠的异步通信能力。在Java开发环境中,ActiveMQ扮演...

    apache-activemq-5.2.0-bin.zip

    这个压缩包“apache-activemq-5.2.0-bin.zip”包含了Apache ActiveMQ 5.2.0版本的源代码、可执行文件和其他必要的组件,使得用户可以在本地环境中部署和运行ActiveMQ服务器。 ActiveMQ 5.2.0是一个重要的里程碑,它...

    activemq-all-5.2.0.jar包

    activemq-all-5.2.0.JAR包,欢迎下载。编写java中间件的时候会用到。这是activemq实现的jms中间件。希望能帮助到你。

    activemq-all-5.2.0-sources.jar

    activemq-all-5.2.0-sources.jar

    apache-activemq-5.16.6-bin.zip

    2. **配置**: 修改conf目录下的activemq.xml文件以定制你的消息代理设置。 3. **创建消息生产者和消费者**: 使用JMS API或者支持的其他协议创建应用程序,发送和接收消息。 4. **访问Web Console**: 浏览器中输入`...

    activemq-rar-5.2.0.rar

    RAR文件主要用于Java EE应用服务器,如JBoss或WebLogic,它包含了一个JCA(Java Connector Architecture)资源适配器,使得应用服务器可以与消息中间件ActiveMQ集成。 描述中提到的“rar”是Java的资源适配器打包...

    activemq-xmpp-5.2.0.jar.zip

    "activemq-xmpp-5.2.0.jar"这个文件就是ActiveMQ与XMPP集成的核心组件,它包含了所有必要的类和库,用于在ActiveMQ中启用XMPP支持。此jar文件是开发人员在项目中整合这两个技术的关键依赖包,可以通过"activemq-xmpp...

    activemqBroker-2.14-SNAPSHOT.war

    activemqBroker插件:activemqBroker-2.14-SNAPSHOT.war

    activemq-rar-5.2.0-sources.jar

    标签:activemq-rar-5.2.0-sources.jar,activemq,rar,5.2.0,sources,jar包下载,依赖包

    消息队列:ActiveMQ:ActiveMQ的Spring集成.docx

    消息队列:ActiveMQ:ActiveMQ的Spring集成.docx

    activemq-ra-5.2.0.jar

    标签:activemq-ra-5.2.0.jar,activemq,ra,5.2.0,jar包下载,依赖包

    activemq-all-5.2.0-jar包.rar

    ActiveMQ 5.2.0版本是其历史上的一个重要里程碑,引入了多项优化和改进,提升了稳定性和性能。 二、JMS基础 JMS(Java Message Service)是Java平台中用于在分布式环境中传递消息的标准API。它定义了生产、发送、...

    C#客户端开发ActiveMq请下载Apache.NMS和Apache.NMS.ActiveMQ两个bin包

    这两个bin包是专门为.NET平台设计的,允许.NET开发者无缝地集成ActiveMQ的功能。 Apache.NMS(Net Messaging System)是Apache项目的一个子项目,它为.NET开发者提供了一组统一的消息API,使得与多种JMS(Java ...

    apache-activemq-5.15.5-bin.tar.gz

    5. 根据需要配置`conf/activemq.xml`以调整服务器设置,如端口、持久化、安全性等。 6. 使用`bin/activemq stop`命令关闭ActiveMQ服务。 在实际应用中,开发人员通常会根据项目需求,通过编程接口与ActiveMQ交互,...

    activemq安装.pdf

    在G:\apache-activemq-5.2.0\data目录下可以找到activemq.log日志文件,查看日志文件可以了解ActiveMQ的启动过程和错误信息。 日志文件解释 日志文件中记录了ActiveMQ的启动过程和错误信息。例如,日志文件中显示...

    apache-activemq-5.13.2-bin.tar.gz

    在启动前,你可能需要根据你的需求修改`conf/activemq.xml`配置文件,设置如broker地址、网络连接、存储策略等参数。 一旦配置完毕,可以通过运行`bin/start.sh`启动ActiveMQ。启动成功后,ActiveMQ默认会在`...

    activemq-test-atomikos-5.2.0.jar

    标签:activemq-test-atomikos-5.2.0.jar,activemq,test,atomikos,5.2.0,jar包下载,依赖包

    apache-activemq-5.15.10-bin.tar.gz

    2. **编写代码** - 使用JMS API创建ConnectionFactory,连接到ActiveMQ服务器,创建MessageProducer和MessageConsumer来发送和接收消息。 3. **测试与优化** - 测试消息传递的性能和可靠性,根据需求调整ActiveMQ的...

    apache-activemq-5.16.5-bin.tar.gz 下载(5积分)

    ActiveMQ使用AMQP协议集成多平台应用,使用STOMP协议通过websockets在Web应用程序之间交换消息,使用MQTT协议管理物联网设备 ActiviMq消息队列,可解决服务解耦合的动作,缓解了服务并发量很大而造成服务器无法处理...

Global site tag (gtag.js) - Google Analytics