首页 > 解决方案 > Configuring ReplyingKafkaTemplate for getting the responses from multiple topics

问题描述

I have a requirement where I must use the synchronous request-reply pattern with Kafka, hence I am using ReplyingKafkaTemplate for the same.

As a part of implementation, there is a producer which is pushing a request message on one topic(input-message-topic1) but in return I am expecting responses from two topics(output-message-topic1 and output-message-topic2) which I have to aggregate and process further.

Question : Is it possible to implement the above scenario with ReplyingKafkaTemplate / AggregatingReplyingKafkaTemplate or any other implementation which uses synchronous request-reply pattern with Kafka ?

标签: apache-kafkakafka-consumer-apispring-kafka

解决方案


Yes, the AggregatingReplyingKafkaTemplate will do this; just configure its listener container to consume from both topics; the replies must contain the correlation id header (used to aggregate).


推荐阅读