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