shuzheng 9 лет назад
Родитель
Сommit
e437392ff9

+ 41 - 0
cms/cms-web/src/main/resources/applicationContext-activemq.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-3.2.xsd"
+	   default-autowire="byName">
+
+	<!-- 连接工厂 -->
+	<bean id="activeMqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+		<property name="brokerURL" value="${AvtiveMQ.brokerURL}"/>
+	</bean>
+	<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
+		<property name="connectionFactory" ref="activeMqConnectionFactory"/>
+		<property name="maxConnections" value="10"/>
+	</bean>
+	<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
+		<property name="targetConnectionFactory" ref="pooledConnectionFactory"/>
+	</bean>
+	<!-- 点对点队列 -->
+	<bean id="defaultQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
+		<constructor-arg index="0" value="com.zheng.cms.queue.default" />
+	</bean>
+	<!-- 一对多队列 -->
+	<!--
+	<bean id="defaultTopicDestination" class="org.apache.activemq.command.ActiveMQTopic">
+		<constructor-arg index="0" value="com.zheng.cms.topic.default" />
+	</bean>
+	-->
+
+	<!-- 生产者 -->
+	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
+		<property name="connectionFactory" ref="connectionFactory"/>
+	</bean>
+	<!-- 消费者 -->
+	<bean id="defaultQueueMessageListener" class="com.zheng.cms.jms.defaultQueueMessageListener"/>
+	<bean id="jmsContainer"  class="org.springframework.jms.listener.DefaultMessageListenerContainer">
+		<property name="connectionFactory" ref="connectionFactory" />
+		<property name="destination" ref="defaultQueueDestination" />
+		<property name="messageListener" ref="defaultQueueMessageListener" />
+	</bean>
+</beans>

+ 3 - 1
cms/cms-web/src/main/resources/profiles/dev.properties

@@ -1 +1,3 @@
-profile.env=dev
+profile.env=dev
+### activeMq的broker地址
+AvtiveMQ.brokerURL=failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0)

+ 3 - 1
cms/cms-web/src/main/resources/profiles/prod.properties

@@ -1 +1,3 @@
-profile.env=prod
+profile.env=prod
+### activeMq的broker地址
+AvtiveMQ.brokerURL=failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0)

+ 3 - 1
cms/cms-web/src/main/resources/profiles/test.properties

@@ -1 +1,3 @@
-profile.env=test
+profile.env=test
+### activeMq的broker地址
+AvtiveMQ.brokerURL=failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0)