0
收到receiveChannel中的消息后,我想调用一个服务来完成一些额外的工作。 消息的流动将是:如何在Spring Integration中将服务分配给消息驱动适配器?
JMS Message -> receiveChannel -- message-driven-adapter --> jmsInChannel -> queueChannel (here the service should be invoked)
我想实现这要么1),其上queueChannel 2调用的服务),或与消息adapater。
在后一种情况下,我不知道如何在Spring集成中为消息驱动适配器分配服务?另外一个服务没有被调用。
此配置包含了这两种方法,但他们没有工作:
<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>
这是我的发送者将消息发送给转发队列:
<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后端。
更新:我添加了一个侦听器,现在收到了这些消息。这是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,[email protected], 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 = [email protected], marshalledProperties = [email protected], dataStructure = null, redeliveryCounter = 0, size = 0, properties = {timestamp=1374155536031, [email protected], 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}]
感谢您的及时答复。这是您的建议后的配置。但是,该服务仍未被调用。 'si:channel id =“jmsInChannel”/> SI:服务激活因子>' –
luksmir
这意味着正在从没有接收到消息队列。打开'org.springframework'的DEBUG日志记录。 –
确实。消息已发送但未收到。你知道为什么吗? [有效载荷= GATEWAY] [接头= {时间戳= 1374,ID = b71f9] [: '[DirectChannel] [AbstractMessageChannel.java] [DEBUG] [主要] postSend信道 'sendChannel',消息(发送=真) ActiveMQConnection] [ActiveMQConnection.java] [DEBUG] [ActiveMQ的运输:TCP:///172.16.33.49:61616 @ 51596]未决中断处理 [PollingConsumer] [AbstractTransactionSynchronizingPollingEndpoint.java] [DEBUG] [通知的故障切换传输(未连接)任务调度-1]所获投票期间没有消息,返回“false'' – luksmir