SOA On Tomcat专题7--内嵌activeMQ

Tomcat内嵌activeMQ是参考《ActiveMQ In Action(Manning-2011).pdf》但是失败了。后面发现是书中描述不全。现将最佳实践提炼出来。


内嵌activeMQ5.4.0,只需要:

1. 增加以下jar包,PS:更正,经过测试,其实spring开头的包只要有spring-2.5.6.jar(2881K)的就可以了




2并在context.xml中配置连接工厂和消息队列的JNDI资源,要注意brokerURL的设置,它只识别"/"。大家最好先参照网上的一些例子,运行下,对原理和概念了解一点,这样才能心知肚明,否则就是苍蝇乱撞了,JMS是个很强大的货,将来会写个专题。

<Resource auth="Container"
              brokerName="MyActiveMQBroker"
              brokerURL="vm://localhost?brokerConfig=xbean:file:${activeMQ.home}/conf/activemq.xml"
              description="JMS Connection Factory"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              name="ConnectionFactory"
              type="org.apache.activemq.ActiveMQConnectionFactory"/>
    
    
    <Resource auth="Container"
              description="My Message Queue"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              name="queue/QueueLog"
              physicalName="QueueLog"
              type="org.apache.activemq.command.ActiveMQQueue"/>  
              <!-- physicalName="QueueLog" equals Queue queue = new ActiveMQQueue("QueueLog");
                                    because OperLogUtils has been Hardware configuration-->

    <Resource auth="Container"
              description="My Message Topic"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              name="queue/TopicEFrame"
              physicalName="TopicEFrame"
              type="org.apache.activemq.command.ActiveMQTopic"/> 

3然后将activeMQ.xml文件拷贝指定路径

<beans
  xmlns="http://www.springframework.org/schema/beans"
  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">
 
 
  <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:${catalina.home}/conf/shine/shine.properties</value>    <!--支持系统属性配置-->
                <value>file:${catalina.home}/conf/shine/shine-default.properties</value>    
            </list>
        </property>
    </bean>
 
  <broker useJmx="false" brokerName="jdbcBroker" xmlns="http://activemq.apache.org/schema/core">
    <persistenceAdapter>
       <jdbcPersistenceAdapter dataDirectory="${catalina.home}/activemq/data" dataSource="#oracle-ds"/>
    </persistenceAdapter>

    <transportConnectors>
       <transportConnector name="default" uri="tcp://${activeMQ.binging.address}:${activeMQ.binging.port}"/>
    </transportConnectors>
  </broker>
 
  <!-- 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:@${com.shine.pub.database.es_system.address}:${com.shine.pub.database.es_system.port}:${com.shine.pub.database.es_system.sid}"/>
    <property name="username" value="${com.shine.pub.database.es_system.user}"/>
    <property name="password" value="es_system"/>
    <property name="maxActive" value="200"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>
 
</beans>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值