什么是 Kafka 事务?

What are Kafka transactions?

Kafka 中的事务是什么意思?我当然知道普通的SQL交易:A transaction is a sequence of operations performed (using one or more SQL statements) on a database as a single logical unit of work

这是否意味着可以向 Kafka 发送一些东西,如果出现问题,它将被回滚(从分区中删除消息?)
是否可以在一个事务中写入不同的主题?

Transactional Producer 允许将数据发送到多个分区并保证所有这些写入要么被提交要么被丢弃。这是通过将对 send() (and optionally sendOffsetsToTransaction()) 的多次调用分组到一个事务中来完成的。

交易开始后,您可以调用commitTransaction() or abortTransaction()来完成它。

配置为 isolation.level=read_committed 的消费者将不会收到来自中止事务的消息。

有关更多详细信息,请查看文档中的 Message Delivery Semantics section