在spring integration <int-jms:inbound-gateway>中配置自定义taskExecutor

时间:2017-01-13 14:07:06

标签: spring-integration spring-jms

目前,我正在寻找配置自定义任务执行程序,即springman的工作管理器。我尝试使用task-executor属性进行配置,但似乎它不支持它。 Reasson在这里,我想将它委托给服务器的线程管理,而不是使用Spring的默认任务执行器。以下是示例配置 -

<jms:inbound-gateway request-destination="getQueue" 
        request-channel="inputChannel" 
        connection-factory="connectionFactory" 
        error-channel="errorChannel" concurrent-consumers="10"
        transaction-manager="transactionManager"  
        reply-delivery-persistent="false" reply-time-to-live="30000" explicit-qos-enabled-for-replies="true"
        />

I have tried to plug the taskExecutor as below, but it doesn't seems to be working.  I am not sure if there is anything wrong with it?  Do I need to provide "messageListener" too with container?  However, I have tried hooking messageListener as well i.e. using ChannelPublishingJmsMessageListener, but that too didn't work.  Here issue is, it is not picking/reading the messages from "destination".

<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
      <property name="workManagerName" value="wm/default" />
</bean>

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />

<jms:inbound-gateway request-channel="inputChannel" error-channel="errorChannel" container="channelContainer"/>

<bean id="channelContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="getQueue" />
<property name="taskExecutor" ref="taskExecutor" />
<property name="transactionManager" ref="transactionManager" />
<property name="concurrentConsumers" value="10" />
<property name="autoStartup" value="true" />
</bean>

<int:chain input-channel="inputChannel">
     <int:transformer method="..." ref="messageTransformer" />
     <int:claim-check-in message-store="messageStore"/>
     <int:header-enricher>
         <int:header name="..." expression="payload" />
     </int:header-enricher>
     <int:claim-check-out message-store="messageStore"/>
     <int:transformer method="..." ref="requestObjectConverter" />
     <int:service-activator method="..." ref="...." />
     <int:transformer method="..." ref="responseObjectConverter" />
     <int:transformer method="...." ref="messageTransformer" />
</int:chain>

<int:chain input-channel="errorChannel">
      <int:transformer method="..." ref="errorTransformer" />
</int:chain>

<bean id="errorTransformer" class="....">
    ......
    <property name="messageStore" ref="messageStore"></property>
    ......
</bean>

1 个答案:

答案 0 :(得分:0)

连接<bean/>类型DefaultMessageListenerContainer并通过container属性将其提供给网关...

<jms:inbound-gateway id="gatewayWithContainerReference"
                     container="messageListenerContainer"
                     request-channel="requestChannel" />

<bean id="messageListenerContainer" 
       class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="testConnectionFactory"/>
    <property name="destinationName" value="testDestination"/>
    <property name="taskExecutor" ref="workManagerTE" />
    ...
</bean>

请注意,某些与JMS相关的属性在容器上,而不是直接在网关上。其他属性保留在网关上。