activemq spring配置
<?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:context="http://www.springframework.org/schema/context"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">

    <!--  
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0" />
</bean>
</property>
<property name="sessionCacheSize" value="10" />
<property name="cacheProducers" value="false" />
</bean>

<bean id="notificationTopicDestination" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="ims.notificationTopic" />
</bean>

<bean id="notificationListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
lazy-init="false">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="notificationTopicDestination" />
<property name="messageListener">
<bean
class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<ref bean="messageDispatcher" />
</constructor-arg>
<property name="defaultListenerMethod" value="onNotificationMessage" />
</bean>
</property>
</bean>


<bean id="alarmTopicDestination" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="ims.alarmTopic" />
</bean>

<bean id="alarmListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
lazy-init="false">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="alarmTopicDestination" />
<property name="messageListener">
<bean
class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<ref bean="messageDispatcher" />
</constructor-arg>
<property name="defaultListenerMethod" value="onAlarmMessage" />
</bean>
</property>
</bean>
-->

<!--
    使用spring的listenerContainer,消息用持久化保存,服务器重启不会丢失
-->
<!--  embedded ActiveMQ Broker -->


<!-- 消息转发器 -->
<bean id="messageDispatcher" class="cn.yicha.core.common.jms.MessageDispatcher"></bean>

<!-- 好友短消息发送 -->
<bean id="smsConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="failover://(tcp://localhost:61616?wireFormat.maxInactivityDuration=0,tcp://localhost:61618?wireFormat.maxInactivityDuration=0)?randomize=true" />
</bean>
</property>
<property name="sessionCacheSize" value="10" />
<property name="cacheProducers" value="false" />
</bean>

<bean id="smsDestination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="Message-Queue" />
</bean>

<bean id="smsJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="smsConnectionFactory"/>
<property name="defaultDestination" ref="smsDestination"/>
<property name="receiveTimeout" value="60000"/>
</bean>
<bean id="notificationSender" class="cn.yicha.core.common.jms.notification.NotificationSender">
<property name="jmsTemplate" ref="smsJmsTemplate"/>
</bean>

<!-- 异步接收消息方案一
<bean id="smsConsumer" class="cn.yicha.sns.common.jms.consumer.SmsConsumer"/>

<bean id="queueListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="smsConnectionFactory" />
<property name="destination" ref="smsDestination" />
<property name="messageListener" ref="smsConsumer" />
</bean>
-->


<bean id="smsMsgListener" class="cn.yicha.sns.common.jms.consumer.SmsMsgListener"/>

<!-- 异步接收消息方案二-->
<bean id="queueListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
lazy-init="false">
<property name="connectionFactory" ref="smsConnectionFactory" />
<property name="destination" ref="smsDestination" />
<property name="messageListener">
<bean
class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<ref bean="messageDispatcher" />
</constructor-arg>
<property name="defaultListenerMethod" value="onNotificationMessage" />
</bean>
</property>
</bean>


</beans>
lunzi   2011-03-04 19:11:05 评论:0   阅读:4104   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog