[英]How to send reply message in spring rabbit correctly?
I have a spring rabbit listener 我有一个春季兔子听众
@Override
public void onMessage(Message message, Channel channel) {
//do something
channel.basicPublish("",queue name, null, SerializationUtils.serialize(r));
}
How rabbit will understand that this response is for my particular message? Rabbit将如何理解此响应是针对我的特定消息的? In case if I have a thousands of messages.
如果我有成千上万的消息。 What I need to do to link request and response?
我需要做什么来链接请求和响应? And is there a way to pass to the channel POJO without serialization?
有没有一种方法可以传递给通道POJO而不进行序列化? Thanks
谢谢
You should take care there about replyTo
and correlation
. 您应该在这里注意
replyTo
和correlation
。
But I'd say that there is no reason to do that manually, because MessageListenerAdapter
takes care about that. 但是我会说没有理由手动执行此操作,因为
MessageListenerAdapter
会注意这一点。
You just need supply a POJO with request-reply capabilities: 您只需要提供一个具有请求-回复功能的POJO:
class Delegate {
@SuppressWarnings("unused")
public String handleMessage(String input) {
called.set(true);
return "processed" + input;
}
}
adapter.setDelegate(new Delegate());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.