Spring Kafka is Acknowledgement.acknowledge thread safe?

匿名 (未验证) 提交于 2019-12-03 01:39:01

问题:

I am implementing an kafka based application where I would like to manually acknowledge incoming messages. Architecture forces me to do it in a separate thread.

The question is: is it possible and safe to execute Acknowledgement.acknowledge() in a different thread than consumer?

回答1:

Yes it is, as long as you use MANUAL and not MANUAL_IMMEDIATE, but I don't think you'll get what you expect.

Kafka doesn't track each message, just offsets within the partition.

Let's say message 1 arrives and you hand off to another thread. Then message 2 arrives and it is handed off to yet another thread.

When the offset for message 2 is ack'd, you are effectively acking both messages.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!