我无法使用带有REST的REST协议来实现请求/答复模式。 我正确地收到了一个请求,并且可以看到一些标头,例如“ solace-correlation-id”和“ solace-message-id”。 我期望返回一个带有正文的http响应作为消息回复,但是我总是进入我的应用程序:
org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: xxxxx-1549904557890-0-26 not received on destination: #P2P/QTMP/v:cfdce68771f5/c9c4ba4a-a427-438a-9b7a-1f069608d13a.
不幸的是,慰藉文档仅涵盖了休息的发布/订阅模式,而没有涵盖请求/回复模式。
答案 0 :(得分:0)
这里可能会发生一些不同的事情。
首先尝试在“ from”和“ to”端点之间添加日志组件,然后在“ to”端点之后再次添加日志,因为这将向您显示答复的标头,例如,使用Java DSL语法:
from("{{fromSource}}" )
.to("log:all?level=INFO&showAll=true&multiline=true")
.to("{{toDest}}" )
.to("log:all?level=INFO&showAll=true&multiline=true")
;
我怀疑相关ID没有传回。在我的示例中,我有一个NodeJS服务,因此我设置了以下响应标头:
res.setHeader('solace-correlation-id', req.get('solace-correlation-id'));
使用其他日志记录,您应该能够看到问题所在。
答案 1 :(得分:0)
您最有可能在回复消息中丢失消息ID或相关ID。
https://docs.solace.com/RESTMessagingPrtl/Solace-REST-Message-Encoding.htm#2.2.6.1
When the Solace message broker receives a possible reply message routed to the HTTP client, it verifies that the reply message's message ID or correlation ID match those of the request message.
Specifically,
- the reply's message ID must match the request's message ID the
- reply's correlation ID must match the request's message ID, or the
- reply's correlation ID must match the request's correlation ID.
If any of those matches occur, the Solace message broker sends the reply message as an HTTP response to the HTTP client.
HTTP requires that there be exactly one HTTP response for each HTTP request, so each matching message ID or correlation ID can be used only in a single request-reply message exchange pattern.
If the reply message does not have a matching message ID or correlation ID as above, or if the reply message's matching message ID or correlation ID has already been consumed by an earlier reply message, the reply message is discarded.