我正在用spring-boot&kafka做一个事务性项目的poc,我有以下疑问:
场景:一个microservices mspub1接收来自客户的请求。该请求在kafka上的topic transaction\u topic1上发布消息,但该微服务可以并行接收多个请求。微服务监听主题transaction\u result1以检查事务是否完成。
在流媒体平台的另一端,另一个微服务mssub1正在监听主题transaction\u topic1,处理所有消息并将结果发布到:transaction\u result1
从mspub1知道主题transaction\u result1上的消息是否与其原始请求匹配的最佳方法是什么?microservice mspub1可以拥有在初始主题transaction\u topic1上发布的任何消息的id,并可以移动到transaction\u result1
问题:当您读取分区时,您移动了指针,但是在具有多个请求的并发环境中,如何检查主题transaction\u result1上的消息是否是预期的?
非常感谢
胡安安东尼奥
1条答案
按热度按时间vx6bjr1n1#
一种方法是使用spring集成
BarrierMessageHandler
.下面是一个示例应用程序。希望这是不言自明的。需要Kafka0.11或更高。。。
结果
聚甲醛
应用程序属性
编辑
这是一个在服务器端使用spring集成的版本,而不是
@KafkaListener
...和