java Apache Kafka 能够处理事务吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32073351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is Apache Kafka able to handle transactions?
提问by padmalcom
we plan to use Kafka as a central component in our data warehouse given that the producer is able to handle transactions (in short: rollbacks and commits).
鉴于生产者能够处理事务(简而言之:回滚和提交),我们计划使用 Kafka 作为我们数据仓库的核心组件。
When googling Kafka + TransactionsI find a lot of theoretical thoughts about the possibility of how Kafka couldhandle transactions but at the moment I do not see any function in the java API that supports commits and rollbacks for the producer.
当谷歌搜索卡夫卡+交易我找了很多关于卡夫卡如何可能性理论的思想可以处理事务,但目前我没有看到Java API中的任何功能,支持提交和回滚的制片人。
Has anybody made some experiences with transactions and Kafka and can give me an hint?
有没有人在交易和Kafka方面有一些经验,可以给我一个提示吗?
回答by mlg
No; Kafka does not support transactions.
不; Kafka 不支持事务。
You can get certainty that a message has been produced to a partition, but once produced you are not able to rollback that message.
您可以确定消息已生成到分区,但一旦生成,您将无法回滚该消息。
Since version 0.11.0 Apache Kafka supports transactions: https://cwiki.apache.org/confluence/display/KAFKA/Transactional+Messaging+in+Kafka
Apache Kafka 从 0.11.0 版本开始支持事务:https://cwiki.apache.org/confluence/display/KAFKA/Transactional+Messaging+in+Kafka
回答by rh0x
Actually, from the last version 0.11.0.0 transactions are supported. See Guarantee unique global transaction for Kafka Producers
实际上,从最新版本 0.11.0.0 开始支持事务。请参阅为 Kafka Producers 保证唯一的全局事务
回答by user2720864
I think what you are looking for is basically called transactional messaging in Kafka where producers are capable of creating session (aka transactional session) and send messages within the sessions. Hence it can choose to either commit / abort the transaction.
我认为您正在寻找的基本上称为 Kafka 中的事务性消息传递,其中生产者能够创建会话(又名事务性会话)并在会话内发送消息。因此它可以选择提交/中止事务。
[Source]: Please read the wikifor details
[来源]:请阅读维基详细内容