首先要在WAS里面配置IBM MQ作为JMS消息的提供者,在WAS管理控制台: Resources->JMS Providers->WebSphere MQ,首先创建一个连接工厂,点击 WebSphere MQ connection factories 填好配置选项,CCSID 注意下这个选项,这个是队列管理器所用到的字符集,中文简体(1381),其他的就没什么要特别注意的地方了,保存后返回到前一页面。点击WebSphere MQ queue destinations 进入后点击NEW进入创建页面,注意 Base queue name 这一选项要填写跟MQ一样的消息队列名称。Target client 有JMS和MQ两个区别,如果你想在队列里面存放java序列化对象就得选JMS,其他选项任意填然后保存。
下面是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:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd "> <jee:jndi-lookup id="connectionFactory" jndi-name="${jms.connection.factory}"> <jee:environment> java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory java.naming.provider.url=iiop://localhost:2809 java.naming.factory.url.pkgs=com.ibm.ws.naming </jee:environment> </jee:jndi-lookup> <jee:jndi-lookup id="destination" jndi-name="${jms.connection.destination}"> <jee:environment> java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory java.naming.provider.url=${jms.provider.url} java.naming.factory.url.pkgs=com.ibm.ws.naming </jee:environment> </jee:jndi-lookup> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="defaultDestination" ref="destination" /> </bean> <bean id="messageProducer" class="govhk.ha.eface.core.jms.MessageProducer"> <property name="jmsTemplate" ref="jmsTemplate" /> </bean> <bean id="messageListener" class="govhk.ha.eface.core.jms.MessageConsumer"> </bean> <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager"> <property name="connectionFactory" ref="connectionFactory" /> </bean> <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="concurrentConsumers" value="5" /> <property name="connectionFactory" ref="connectionFactory" /> <property name="destination" ref="destination" /> <property name="messageListener" ref="messageListener" /> <property name="transactionManager" ref="jmsTransactionManager" /> </bean> <bean id="mailSender" class="govhk.ha.eface.core.mail.MailSender"> <property name="messageProducer" ref="messageProducer" /> </bean>?
?
1 楼
absolute
2007-09-17
在WAS中建立队列连接工厂,“资源”----“JMS提供者”----“Websphere MQ”----“Websphere MQ队列连接工厂”----“新建”。填写以下内容:
名称: connectionFactory
JNDI名称: jms/connectionFactory
队列管理器: alex_queue_manager
主机: 192.168.0.120
端口: 1414
通道: alex_s_channel
传输类型: CLIENT
取消“已起用XA”选项
建立队列目标。“资源”----“JMS提供者”----“Websphere MQ”----“Websphere MQ队列目标”----“新建”。填写以下内容:
名称: destination
JNDI名称: jms/destination
基本队列名: alex_mail_queue
CCSID: 1381
目标客户机: JMS
配置侦听器端口,“服务器”----“应用服务器”----“server1”----“通信”----“消息传递”----“消息侦听器服务”----“侦听器端口”----“新建”。填写一下内容:
名称: listener
连接工厂JNDI名: jms/connectionFacotry
目标JNDI名: jms/destination
重启websphere使配置生效。
名称: connectionFactory
JNDI名称: jms/connectionFactory
队列管理器: alex_queue_manager
主机: 192.168.0.120
端口: 1414
通道: alex_s_channel
传输类型: CLIENT
取消“已起用XA”选项
建立队列目标。“资源”----“JMS提供者”----“Websphere MQ”----“Websphere MQ队列目标”----“新建”。填写以下内容:
名称: destination
JNDI名称: jms/destination
基本队列名: alex_mail_queue
CCSID: 1381
目标客户机: JMS
配置侦听器端口,“服务器”----“应用服务器”----“server1”----“通信”----“消息传递”----“消息侦听器服务”----“侦听器端口”----“新建”。填写一下内容:
名称: listener
连接工厂JNDI名: jms/connectionFacotry
目标JNDI名: jms/destination
重启websphere使配置生效。