c++springapache-kafkaspring-kafkalibrdkafka

Spring Kafka: C++ producer of reply for ReplyingKafkaTemplate


I use ReplyingKafkaTemplate to send a request to Kafka and receive the reply. Consumer of the request is a C++ program. After processing the request, its reply is produced by the C++ application. Now my problem is about format of the reply, because it seems that consumer of the reply in spring-side uses correlation Id to find corresponding reply. Can somebody help me about this problem?


Solution

  • You need to echo back the correlationId header so the template knows which request this reply is for. Simply set the header on the reply in your C++ code to the value of the incoming request header.