IBM Mq Spring JMS 的xml配置
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.2.xsd">
<!-- WebSphere MQ Connection Factory -->
<bean id="targetConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName">
<value>${esbmon.mq.hostname}</value>
</property>
<property name="port">
<value>${esbmon.mq.port}</value>
</property>
<property name="queueManager">
<value>${esbmon.mq.queueManagerName}</value>
</property>
<property name="channel">
<value>${esbmon.mq.channel}</value>
</property>
<!-- com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP=1 -->
<property name="transportType" value="1" />
</bean>
<!-- Spring用于管理真正的ConnectionFactory的ConnectionFactory;
MessageListenerContainer已经建立缓存机制,这里直接使用SingleConnectionFactory而不是
CachingConnectionFactory
-->
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
<!-- 目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory -->
<property name="targetConnectionFactory" ref="targetConnectionFactory"/>
<!-- 使用SingleConnectionFactory时,开启reconnectOnException很重要 -->
<property name="reconnectOnException" value="true"></property>
</bean>
<!-- JMS Destination Resolver -->
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.DynamicDestinationResolver">
</bean>
<!-- 事务管理器,将messageListener的onMessage方法作为一个事务 -->
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<!-- 配置成 jta事物,是消息接受事物和数据库操作事物失败都能回滚-->
<bean id="jtaTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="connectionFactory" ref="connectionFactory" />
<property name="sessionTransacted" value="true" />
</bean>
<!-- 任务处理线程池 -->
<bean id="jmsListenerTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize">
<value>${esbmon.jmsListenerExecutor.corePoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${esbmon.jmsListenerExecutor.maxPoolSize}</value>
</property>
<property name="keepAliveSeconds">
<value>${esbmon.jmsListenerExecutor.keepAliveSeconds}</value>
</property>
<property name="queueCapacity">
<value>${esbmon.jmsListenerExecutor.queueCapacity}</value>
</property>
<property name="rejectedExecutionHandler">
<bean class="${esbmon.jmsListenerExecutor.handler}" />
</property>
<property name="threadNamePrefix" value="jmsListenerTaskExecutor" />
</bean>
<!-- jms listenercontainer用于异步接受消息,JmsTemplate类用来生产消息和同步接收消息 -->
<!-- container-type:容器的类型, default、simple、default102 或者 simple102 -->
<!-- connection-factory:JMS ConnectionFactory Bean的引用 -->
<!-- task-executor:JMS TaskExecutor Bean的引用 -->
<!-- destination-resolver:DestinationResolver 策略的引用 -->
<!-- message-converter:MessageConverter 策略的引用用 -->
<!-- destination-type:目的地类型,queue、topic 或者 durableTopic -->
<!-- client-id:容器在JMS客户端的id -->
<!-- acknowledge: JMS消息的确认模式,auto、client、dups-ok 或者 transacted -->
<!-- transaction-manager:PlatformTransactionManager Bean的引用 -->
<!-- concurrency:可激活的Session最大并发数 -->
<!-- prefetch:加载进每个Session的最大消息数,增加这个值会造成并发空闲 -->
<!-- receive-timeout:每次接收消息的超时时间 -->
<!-- cache:缓存级别 -->
<jms:listener-container container-type="default"
connection-factory="jtaTransactionManager" destination-type="queue"
transaction-manager="jmsTransactionManager" task-executor="jmsListenerTaskExecutor"
destination-resolver="jmsDestinationResolver" concurrency="30" prefetch="100"
receive-timeout="3000" acknowledge="transacted">
<!-- id: 容器的Bean名称 -->
<!-- destination: 目的地的名称,由DestinationResolver的策略决定 -->
<!-- ref: 处理对象的Bean名称 -->
<!-- method: 处理器中被调用的方法名, 如果ref指向 MessageListener或SessionAwareMessageListener,则这个属性可以被忽略 -->
<!-- selector: 可选的消息选择器 -->
<jms:listener id="svcLogListener" destination="${esbmon.mq.queueName.serviceLog}"
ref="svcLogJmsListener" />
<jms:listener id="sysLogListener" destination="${esbmon.mq.queueName.systemLog}"
ref="sysLogJmsListener" />
<jms:listener id="MqLogListener" destination="${esbmon.mq.queueName.mqSvcLog}"
ref="pubSubLogJmsListener" />
</jms:listener-container>
</beans>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。