對於一個項目,我必須在ActiveMQ主題上使用請求 - 響應模式,我知道回答一個主題並不是一個好習慣,但不幸的是我必須這樣做。 我的問題是,如果我使用jms:output-endpoint上的exchange-pattern =「request-response」屬性(發佈請求消息),該消息將發佈兩次!所以用戶收到消息兩次,併發送他的回覆兩次。Mule Jms在主題中的請求響應
使用請求響應路由器它工作(這意味着消息只發送一次)。 但我想使用自動生成的臨時主題,所以我寧願使用exchange-pattern =「request-response」而不是請求響應路由器。
輸出端點發送消息兩次是否有原因? 如果沒有其他可能性使用請求響應路由器,是否可以在那裏生成臨時主題?
我做了簡短的程序與發佈商(mule.componentA),並且其中所述消息是發送兩倍的訂戶(mule.componentB):
<jms:activemq-connector brokerURL="tcp://localhost:61616" name="JMS_Connector" doc:name="Active MQ" specification="1.1" validateConnections="true" />
<flow doc:name="mule.componentA" name="mule.componentA">
<http:inbound-endpoint host="localhost" port="8081" doc:name="HTTP" exchange-pattern="one-way" path="componentA" />
<set-payload value="hello" doc:name="Set Payload"/>
<logger message="componentA send: parameter: #[message.payload]" level="INFO" doc:name="Logger"/>
<jms:outbound-endpoint connector-ref="JMS_Connector" doc:name="JMS" exchange-pattern="request-response" topic="topic.test"/>
<logger message="componentA received. message: #[message.payload]" level="INFO" doc:name="Logger" />
</flow>
<flow doc:name="mule.componentB" name="mule.componentB">
<jms:inbound-endpoint connector-ref="JMS_Connector" doc:name="JMS" exchange-pattern="one-way" topic="topic.test"/>
<logger message="componentB received. message: #[message.payload]" level="INFO" doc:name="Logger" />
<set-payload value="world" doc:name="Set Payload"/>
<logger message="componentB send: message: #[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
在HTTP:入站端點是啓動觸發流量。我用firefox和curl試了一下,但沒有什麼不同。
輸出是:
INFO 2014-01-21 16:12:29,760 [[request_response].mule.componentA.stage1.02] org.mule.api.processor.LoggerMessageProcessor: componentA send: parameter: hello
INFO 2014-01-21 16:12:29,761 [[request_response].mule.componentA.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
INFO 2014-01-21 16:12:29,762 [[request_response].mule.componentA.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
WARN 2014-01-21 16:12:29,762 [[request_response].mule.componentA.stage1.02] com.mulesoft.mule.transport.jms.EeJmsMessageDispatcher: Starting patched JmsMessageReceiver
INFO 2014-01-21 16:12:29,762 [[request_response].mule.componentA.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'JMS_Connector.dispatcher.191522199'. Object is: EeJmsMessageDispatcher
INFO 2014-01-21 16:12:29,762 [[request_response].mule.componentA.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'JMS_Connector.dispatcher.191522199'. Object is: EeJmsMessageDispatcher
INFO 2014-01-21 16:12:29,822 [[request_response].mule.componentB.stage1.02] org.mule.api.processor.LoggerMessageProcessor: componentB received. message: hello
INFO 2014-01-21 16:12:29,823 [[request_response].mule.componentB.stage1.02] org.mule.api.processor.LoggerMessageProcessor: componentB send: message: world
INFO 2014-01-21 16:12:29,826 [[request_response].mule.componentB.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
INFO 2014-01-21 16:12:29,828 [[request_response].mule.componentB.stage1.03] org.mule.api.processor.LoggerMessageProcessor: componentB received. message: hello
INFO 2014-01-21 16:12:29,829 [[request_response].mule.componentB.stage1.03] org.mule.api.processor.LoggerMessageProcessor: componentB send: message: world
INFO 2014-01-21 16:12:29,830 [[request_response].mule.componentB.stage1.03] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
INFO 2014-01-21 16:12:29,832 [[request_response].mule.componentB.stage1.02] org.mule.transport.jms.JmsReplyToHandler: Reply Message sent to: temp-topic://ID:philipps-mbp-62486-1390317145516-1:1:1 with correlationID:ID:philipps-mbp-62486-1390317145516-1:1:3:1:1
INFO 2014-01-21 16:12:29,833 [[request_response].mule.componentB.stage1.03] org.mule.transport.jms.JmsReplyToHandler: Reply Message sent to: temp-topic://ID:philipps-mbp-62486-1390317145516-1:1:1 with correlationID:ID:philipps-mbp-62486-1390317145516-1:1:3:1:2
INFO 2014-01-21 16:12:29,837 [[request_response].mule.componentA.stage1.02] org.mule.api.processor.LoggerMessageProcessor: componentA received. message: world
爲什麼在流程mule.componentB的jms:inbound-endpoint中進行exchange-pattern =「one-way」? – user1493140