12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.apache.org/schema/core"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
-
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-4.2.xsd
-
- http://www.springframework.org/schema/jms
- http://www.springframework.org/schema/jms/spring-jms-4.2.xsd
-
- http://activemq.apache.org/schema/core
- http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd">
- <!-- 引入properties配置文件 -->
- <context:property-placeholder location="classpath*:activemq.properties"
- ignore-unresolvable="true" />
- <!-- 监听注解支持 -->
- <jms:annotation-driven />
- <!-- 连接 activemq -->
- <amq:connectionFactory id="jmsConnectionFactory"
- brokerURL="tcp://${activemq.ip}:${activemq.port}" userName="${activemq.username}"
- password="${activemq.password}" />
- <!-- 这里可以采用连接池的方式连接PooledConnectionFactoryBean -->
- <bean id="jmsConnectionFactoryExtend"
- class="org.springframework.jms.connection.CachingConnectionFactory">
- <constructor-arg ref="jmsConnectionFactory" />
- <!-- 会话的最大连接数 -->
- <property name="sessionCacheSize" value="100" />
- </bean>
- <!-- 消息处理器 -->
- <bean id="jmsMessageConverter"
- class="org.springframework.jms.support.converter.SimpleMessageConverter" />
- <!-- Spring JmsTemplate 的消息生产者 start -->
- <!-- 定义JmsTemplate的Queue类型 -->
- <bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
- <constructor-arg ref="jmsConnectionFactoryExtend" />
- <!-- 非pub/sub模型,即队列模式 -->
- <property name="pubSubDomain" value="false" />
- <property name="messageConverter" ref="jmsMessageConverter"></property>
- </bean>
- <!-- 定义JmsTemplate的Topic类型 -->
- <bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
- <constructor-arg ref="jmsConnectionFactoryExtend" />
- <!-- pub/sub模型(发布/订阅) -->
- <property name="pubSubDomain" value="true" />
- <property name="messageConverter" ref="jmsMessageConverter"></property>
- </bean>
- <bean class="com.lote.wms.common.core.mq.QueueProducer" />
- <bean class="com.lote.wms.common.core.mq.TopicProducer" />
- <!--Spring JmsTemplate 的消息生产者 end -->
- <bean id="jmsListenerContainerFactory"
- class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
- <property name="connectionFactory" ref="jmsConnectionFactoryExtend" />
- </bean>
- </beans>
|