0

在 receiveChannel 收到消息后,我想调用一个服务来做一些额外的工作。消息流将是:

JMS Message -> receiveChannel -- message-driven-adapter --> jmsInChannel -> queueChannel (here the service should be invoked)

我想通过 1) 在 queueChannel 2) 上调用的服务或使用消息适配器来实现这一点。

在后一种情况下,我不知道如何在 Spring Integration 中将服务分配给消息驱动适配器?也没有调用服务。

此配置包含两种方法,但它们都不起作用:

<int-jms:channel id="receiveChannel" 
    queue-name="FORWARD"
    connection-factory="connectionFactory" 
    auto-startup="true">
</int-jms:channel>

<si:channel id="jmsInChannel"/>
<int-jms:message-driven-channel-adapter id="messageDrivenAdapter"
    channel="receiveChannel" destination-name="jmsInChannel"/>
<si:bridge input-channel="jmsInChannel" output-channel="queueChannel"/> 

<si:channel id="queueChannel">
    <si:queue/>
</si:channel>


 <si:service-activator id ="activator" ref="messageService" 
    method="processMessage" 
    input-channel="queueChannel">
</si:service-activator>

这是我将消息发送到 FORWARD 队列的发件人:

 <si:channel id="sendChannel"/>
<int-jms:outbound-channel-adapter 
connection-factory="connectionFactory" 
destination-name="FORWARD" 
channel="sendChannel"/>

<si:gateway id="forwardGateway" 
    service-interface="com.ucware.ucpo.forward.jms.MessageGateway" 
    default-request-channel="sendChannel"/>

消息来自 ActiveMQ 后端的 FORWARD 队列。

更新:我添加了一个监听器,现在收到了消息。这是开启了 TRACE 的日志文件:

18.07.2013 15:52:16.036 [DirectChannel] [AbstractMessageChannel.java] [DEBUG] [main]
postSend (sent=true) on channel 'inputChannel', message: [Payload={FORWARD_ALL=3000, LINE=601}    
[Headers={timestamp=1374155536031, id=c2895e24-2260-4af8-9b23-a226ae95c31f,   
source=PRESENCE_ENGINE,userid=alice@tkb.local, type=FORWARD}]

18.07.2013 15:52:16.036 [ActiveMQMessageConsumer] [ActiveMQMessageConsumer.java] [TRACE] [org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] ID:Lmiroslaw-PC-59127-1374155535776-1:1:1:1 **received message: MessageDispatch** {commandId = 0, responseRequired = false, consumerId = ID:Lmiroslaw-PC-59127-1374155535776-1:1:1:1, destination = queue://FORWARD, message = ActiveMQObjectMessage {commandId = 11, responseRequired = true, messageId = ID:Lmiroslaw-PC-59127-1374155535776-1:1:3:1:3, originalDestination = null, originalTransactionId = null, producerId = ID:Lmiroslaw-PC-59127-1374155535776-1:1:3:1, destination = queue://FORWARD, transactionId = null, expiration = 0, timestamp = 1374155536032, arrival = 0, brokerInTime = 1374155536013, brokerOutTime = 1374155536013, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@1bc4ec8, marshalledProperties = org.apache.activemq.util.ByteSequence@1d840d9, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {timestamp=1374155536031, userid=alice@tkb.local, source=PRESENCE_ENGINE, type=FORWARD}, readOnlyProperties = true, readOnlyBody = true, droppable = false}, redeliveryCounter = 0}

18.07.2013 15:52:16.037 [DefaultMessageListenerContainer] [AbstractPollingMessageListenerContainer.java] [DEBUG] [org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] **Received message of** type [class org.apache.activemq.command.ActiveMQObjectMessage] from consumer [Cached JMS MessageConsumer: ActiveMQMessageConsumer { value=ID:Lmiroslaw-PC-59127-1374155535776-1:1:1:1, started=true }] of session [Cached JMS Session: ActiveMQSession {id=ID:Lmiroslaw-PC-59127-1374155535776-1:1:1,started=true}]
4

1 回答 1

1

<int-jms:channel/>不用于启动流程 - 它用于在流程中提供消息持久性。

您不需要前两个元素;只需配置消息驱动的适配器,destination-name="FORWARD"它就会从该队列接收消息。

另外,删除queueChannel; 不需要;该服务将在侦听器线程上调用。

message-driven-adapter->jmsInChannel->service-activator

于 2013-07-17T13:35:09.807 回答