在JAVA中使用Spring JMS集成Websphere MQ,Topic发布和订阅

转自:http://blog.sincerad.com/archives/%E5%9C%A8java%E4%B8%AD%E4%BD%BF%E7%94%A8spring-jms%E9%9B%86%E6%88%90websphere-mq%EF%BC%8Ctopic%E5%8F%91%E5%B8%83%E5%92%8C%E8%AE%A2%E9%98%85


<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd"> <!-- MQ链接工厂对象 -->
<bean id="topicConnectionFactory" class="com.ibm.mq.jms.MQTopicConnectionFactory">
<!-- MQ服务器地址 -->
<property name="hostName" value="127.0.0.1" />
<!-- 端口 -->
<property name="port" value="1414" />
<!-- MQ消息队列管理器 -->
<property name="queueManager" value="QM1" />
<!-- MQ通道 -->
<property name="channel" value="SYSTEM.DEF.SVRCONN" />
<!-- 链接方式 -->
<property name="transportType" value="1" />
<!-- TCP --> </bean>
<!-- MQ Topic模板 -->
<!-- 发布消息 jmsTopicTemplate.convertAndSend("topic://test", "Hello world!"); -->
<bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate"> <constructor-arg ref="topicConnectionFactory" />
<!-- Topic 需要加入 -->
<property name="pubSubDomain" value="true" />
</bean>
<!-- 消息监听器1 -->
<bean id="messageListener" class="com.ii2d.mq.MessageListenerForTest" />
<!-- 消息监听器2 --> <bean id="messageListener2" class="com.ii2d.mq.MessageListenerForTest" />
<!-- 把监听器加入到Spring消息监听管理容器 -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="topicConnectionFactory" />
<property name="destinationName" value="topic://test" /> <property name="messageListener" ref="messageListener" /> <property name="pubSubDomain" value="true" /> </bean>
<!-- 把监听器加入到Spring消息监听管理容器 -->
<bean id="jmsContainer2" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="topicConnectionFactory" />
<property name="destinationName" value="topic://test" /> <property name="messageListener" ref="messageListener2" /> <property name="pubSubDomain" value="true" />
</bean>
</beans>
展开阅读全文

没有更多推荐了,返回首页