Search code examples
spring-kafka

Using ReplyingKafkaTemplate across two different applications


I have a spring boot application1 that send a message to request topic. On receiving this message a different spring boot application2 consumes message does processing and sending response in response topic. Can I use replying-template in application1 for this integration. In application2 do I need make changes so that correlational is sent back while sending response in application2?


Solution

  • If application2 uses a @KafkaListener with a non-void return type, the listener adapter will take care of the correlation id.

    If it's a void @KafkaListener and you are sending the reply with a KafkaTemplate (or some other means) then, yes, you need to propagate the correlation id header from the inbound message into the reply.