消费者将如何阅读提交的消息?

How a consumer will read committed messages?

因此,据我从 Transactions in Apache Kafka 了解到,read_committed 消费者不会 return正在进行的交易。因此,我猜想,消费者可以选择将其偏移量提交到那些正在进行的事务消息(例如,读取非事务消息)或者选择在遇到的事务 committed/aborted 之前不再进行进一步的推进。我只是想(Kafka)将允许它跳过那些待处理的交易记录,但是考虑到它的偏移量可能已经很远了,消费者在提交时将如何读取它们?

更新

考虑到该主题可能混合了来自非事务性生产者和事务性生产者的记录(又名消息)。例如,考虑来自主题的 partition

non-transact-Xmsg,from-transact-producer1-msg,from-transact-producer2-msg,non-transact-Ymsg

如果 consumer 遇到 from-transact-producer1-msg 他会跳过消息然后阅读 non- transact-Ymsg 或者他会在尚未提交的 from-transact-producer1-msg 之前挂起并且这样做不会读取 non -transact-Ymsg?

还请考虑可能有许多交易生产者和 from-transact-producer1-msg 的许多等价物,有些承诺了,有些则没有。因此,from-transact-producer2-msg 在消费者到达 non-transact-Xmsg.[=11 时可能是一个承诺的=]

您的要求不是 100% 清楚,但如果我没弄错,您希望能够重新处理一些已使用的消息,这些消息由于某种原因您在第一次使用时无法成功处理。并且 - 您不想收到 "stuck" 这些消息,您更愿意继续处理这些消息。 在这种情况下,最好的选择可能是将它们写入 不同的 队列,并让另一个消费者读取这些 "failed" 消息并根据需要重试。

来自关于 isolation.level 的文档:

Messages will always be returned in offset order. Hence, in read_committed mode, consumer.poll() will only return messages up to the last stable offset (LSO), which is the one less than the offset of the first open transaction. In particular any messages appearing after messages belonging to ongoing transactions will be withheld until the relevant transaction has been completed. As a result, read_committed consumers will not be able to read up to the high watermark when there are in flight transactions.