在两个不同的应用程序中使用 ReplyingKafkaTemplate

Using ReplyingKafkaTemplate across two different applications

我有一个 spring 引导应用程序 1,它向 request 主题发送消息。收到此消息后,另一个 spring 启动应用程序 2 使用消息在 response 主题中进行处理和发送响应。我可以在 application1 中使用 replying-template 进行此集成吗?在 application2 中,我是否需要进行更改,以便在 application2 中发送响应时发回相关信息?

如果 application2 使用具有非空 return 类型的 @KafkaListener,侦听器适配器将处理关联 ID。

如果它是 void @KafkaListener 并且您使用 KafkaTemplate(或其他方式)发送回复,那么,是的,您需要从入站消息到回复中。