【问题标题】:how to handle the following using kafka如何使用kafka处理以下问题
【发布时间】:2017-06-30 08:26:52
【问题描述】:

假设我有以下情况

producer sends the following instructions on to kafka : 
1. "debit 100 from account A"
2. "send email to user A that his account is debited by 100"
and there is a consumer that does the following :
1. does the actual work of 'debit 100'
2. does the actual work of 'sending mail'

说,消费者实例崩溃了,我启动了另一个实例。 现在,消费者告诉kafka“重播”(以具体化其数据视图) 就现实世界而言,消费者不应该按照这些指令采取行动(这将导致不需要的借记和电子邮件),而只是阅读数据并做任何需要实现其观点的事情。

问题是,消费者如何知道它之前已经对一条消息“采取了行动”,因此,不应该重新采取行动。它只需要在内部捕获消息状态信息吗?

【问题讨论】:

    标签: apache-kafka


    【解决方案1】:

    您可以做的一件事是让您的消费者手动提交偏移量。为此,您需要将默认使用者配置 enable.auto.committrue 更改为 false。然后,在您的消费者应用程序中,在您成功处理消息后,您提交偏移量。

    【讨论】:

      猜你喜欢
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 2020-11-06
      • 1970-01-01
      • 2017-05-18
      • 1970-01-01
      相关资源
      最近更新 更多