简体   繁体   English

Kafka 死信队列,仅用于具有相同密钥的消息

[英]Kafka dead letter queue, for messages with same key only

I have a kafka topic HrEvents , which contains a lot of Hire , Fire , Quit , Promotion and Demotion messages.我有一个 kafka 主题HrEvents ,其中包含很多HireFireQuitPromotionDemotion消息。 Each HR event message has an employee_id property (also the key used for partitioning) and a data property which may contain arbitrary details about the HR event.每个 HR 事件消息都有一个employee_id属性(也是用于分区的键)和一个data属性,其中可能包含有关 HR 事件的任意详细信息。

The problem is that the various data blobs that my application needs to be able to handle are not well documented, and there is a chance that - at any moment - a HR event may be consumed that the application cannot process.问题是我的应用程序需要能够处理的各种data blob 没有得到很好的记录,并且有可能 - 在任何时候 - 可能会消耗应用程序无法处理的 HR 事件。
It is important that - for each employee_id - the application processes all HR events in order.重要的是 - 对于每个employee_id - 应用程序按顺序处理所有 HR 事件。 It is also important that following such a processing failure affecting one employee_id , all HR events for all other employee_id s can continue.同样重要的是,在影响一个employee_id的处理失败之后,所有其他employee_id的所有 HR 事件都可以继续。

The failing HR event, and all subsequent HR events for the same employee_id should be published to a dead letter queue.失败的 HR 事件,以及同一个employee_id所有后续 HR 事件都应该发布到死信队列中。 Once the application has been patched - and support for another undocumented form of data blob has been added - these HR events can be consumed from the dead letter queue.一旦修补了应用程序——并且添加了对另一种未记录形式的data blob 的支持——这些 HR 事件可以从死信队列中使用。

I realize that this also requires maintaining some form of key blacklist in the consumer, inside which employee_id s for which at least one unconsumed HR event message sits in the dead letter queue are stored.我意识到这也需要在消费者中维护某种形式的密钥黑名单,其中存储了至少一条未使用的 HR 事件消息位于死信队列中的employee_id s。

Are there existing solutions/java libraries that allow me to implement a solution to this problem?是否有现有的解决方案/java 库可以让我实现这个问题的解决方案?


Please forgive my ignorance, but I'm trying to find a solution for the problem described above, but I suspect I might not be searching with the correct jargon.请原谅我的无知,但我正在尝试为上述问题找到解决方案,但我怀疑我可能没有使用正确的术语进行搜索。 Feel free to educate me.随意教育我。

Sounds like you should be able to utilize Kafka Streams for this.听起来您应该能够为此使用 Kafka Streams。

Your dead letter queue can build up a KTable, which forms a type of blacklist.你的死信队列可以建立一个KTable,形成一种黑名单。 As new events come in the original topic, you'd perform lookups against the KTable for existing ids and append incoming events into the value list of events yet to process for that ID当原始主题中出现新事件时,您将针对 KTable 执行现有 ID 的查找,并将传入事件附加到尚未针对该 ID 处理的事件的值列表中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM