• Spring下ActiveMQ的xml配置


     <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
     xmlns:cache="http://www.springframework.org/schema/cache" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-4.0.xsd
     http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
     http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.0.xsd">
     
     <!--连接池 ActiveMQ为我们提供了一个PooledConnectionFactory,通过往里面注入一个ActiveMQConnectionFactory 
     可以用来将Connection、Session和MessageProducer池化,这样可以大大的减少我们的资源消耗,要依赖于 activemq-pool包 --> 
     <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop"> 
     <property name="connectionFactory"> 
     <bean class="org.apache.activemq.ActiveMQConnectionFactory"> 
     <property name="brokerURL" value="tcp://localhost:61616" /> 
     </bean> 
     </property> 
     </bean> 
     
     <!-- 连接工厂 -->
     <bean id="activeMQConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> 
     <property name="brokerURL" value="tcp://localhost:61616" /> 
     <!-- <property name="brokerURL" value="ws://localhost:61614" /> --> 
     </bean> 
     
     <!-- 配置消息目标 -->
     <bean id="queryDestination" class="org.apache.activemq.command.ActiveMQQueue">
     
     <constructor-arg index="0" value="greetings" /> 
     </bean> 
     
     <!-- 定义消息Destination -->
     <bean id="topicDestination" class="org.apache.activemq.command.ActiveMQTopic">
     <constructor-arg value="/topic/greetings"/>
     </bean>
     
     
     <!-- 消息模板 -->
     <bean id="queryJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory" ref="activeMQConnectionFactory" /> 
     <property name="defaultDestination" ref="queryDestination" /> 
     <property name="messageConverter"> 
     <bean class="org.springframework.jms.support.converter.SimpleMessageConverter" />
     </property> 
     </bean> 
     
     <!-- 消息发送者客户端 -->
     <bean id="topicJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
     <property name="connectionFactory" ref="activeMQConnectionFactory" />
     <property name="defaultDestination" ref="topicDestination" />
     <property name="messageConverter"> 
     <bean class="org.springframework.jms.support.converter.SimpleMessageConverter" />
     </property> 
    <!-- 开启订阅模式 --> <property name="pubSubDomain" value="true"/> <property name="receiveTimeout" value="10000" />
    <!-- deliveryMode, priority, timeToLive 的开关要生效,必须配置为true,默认false--> <property name="explicitQosEnabled" value="true"/>
    <!-- 发送模式 DeliveryMode.NON_PERSISTENT=1:非持久 ; DeliveryMode.PERSISTENT=2:持久 --> <property name="deliveryMode" value="2"/> </bean>
  • 相关阅读:
    Mysql的左外连接丶右外连接与内连接的区别
    常见的异常种类
    Mysql
    JSTL 标签库
    VMware的虚拟机为什么ip地址老是自动变化?
    redis出现的问题
    在Linux系统下启动了tomcat,但是在游览器中进步了服务
    Linux下安装JDK 与 tomcat
    wamp配置多站点域名
    终端链接操作redis
  • 原文地址:https://www.cnblogs.com/jbml-154312/p/7300117.html
Copyright © 2020-2023  润新知