使用 ReplyingKafkaTemplate 处理多个响应 [英] Handle multiple responses with ReplyingKafkaTemplate

查看:25
本文介绍了使用 ReplyingKafkaTemplate 处理多个响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一种回复响应模式,在该模式中,我向多个消费者组收听的主题发布消息.这意味着他们都会收到消息并在回复主题中提交回复.

I'm trying to implement a reply response pattern in which I publish a message to a topic listened to by several consumer groups. That means that they will all get the message as well as submit the response in the reply topic.

问题是因为他们都回复同一个消息,只有回复主题中第一个收到的消息才会被回复.其他的将被丢弃.鉴于我知道我应该在回复主题上得到多少回复(调用那个数字-n),我怎样才能让 ReplyingKafkaTemplate 等待 n 个回复然后解决答案?我试过从 Spring Kafka 文档 推断,但是无法完全弄清楚.谢谢.

The problem is because they all respond to the same message, only the first received message in the reply topic shall be answered. The others will be discarded. Given that I know how many responses I should be getting on the reply topic(call that number-n), how can I make ReplyingKafkaTemplate wait for n responses and then resolve the answer? I've tried inferring from the Spring Kafka documentation but could not quite figure it out. Thanks.

推荐答案

该模板严格用于单个请求/回复处理.

That template is strictly for single request/reply processing.

您不能将其用于您的用例.

You can't use it for your use case.

使用 KafkaTemplate 和单独的监听器;您必须自己关联回复.

Use a KafkaTemplate and a separate listener; you will have to correlate the replies yourself.

这篇关于使用 ReplyingKafkaTemplate 处理多个响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆