gpt4 book ai didi

java - Spring 和 ActiveMQ 的响应消息中缺少相关 ID

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:10 24 4
gpt4 key购买 nike

我正在通过一个非常简单的实验来学习 Spring Integration。我在ActiveMQ中设置了两个队列,即requestQueue和responseQueue。我想要做的是将消息发送到请求队列,然后应用程序将拾取并回显到响应队列。这是integration.xml中的配置

<int:channel id="requestChannel"/>
<int:channel id="responseChannel"/>
<int:service-activator id="echoServiceActivator" input-channel="requestChannel" ref="echoServiceImpl"
requires-reply="true" output-channel="responseChannel"/>

<jms:inbound-gateway request-channel="requestChannel" reply-channel="responseChannel"
connection-factory="jmsConnectionFactory"
request-destination="requestQueue" default-reply-destination="responseQueue"
id="echoGateway" />

以及服务类

@Service
public class EchoServiceImpl implements EchoService {

private static final Logger logger = LoggerFactory.getLogger(EchoServiceImpl.class);

@Override
@ServiceActivator
public String echo(Message<String> message) {
logger.info("Received message: {}", message.getPayload());
return message.getPayload();
}
}

响应队列中的内容一切顺利。问题是相关 ID 永远不会出现。我希望它将包含请求消息的消息 ID。我尝试为入站网关的相关键属性赋予不同的值,但没有成功。是否有问题或者入站网关一开始就不应该使用?

最佳答案

网关关联处理逻辑为 here .

伪代码:

If the gateway has a `correlation-key`
if the correlation key is `JMSCorrelationID`
echo the inbound `message.JMSCorrelationID`
else
echo the inbound correlation key header
else
if the inbound message has a `JMSCorrelationID`
echo the inbound `message.JMSCorrelationID`
else
set the `reply.JMSCorrelationID` to the inbound `message.JMSMessageID`

关于java - Spring 和 ActiveMQ 的响应消息中缺少相关 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38932609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com