Skip to content

Handle multiple responses with ReplyingKafkaTemplate #998

@gkohen

Description

@gkohen

🎁 Enhancement
Continued thread from Stackoverflow.
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.

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

There were few options suggested amongst one is to extend ReplyingKafkaTemplate to support the feature or implement a timer after which you can return partial responses.
At this point ReplyingKafkaTemplate is not really built for extensions and might require almost wholesale copy of the whole class rather than extending it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions