Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Apache Kafka able to handle transactions?

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).

When googling Kafka + Transactions I find a lot of theoretical thoughts about the possibility of how Kafka could handle transactions but at the moment I do not see any function in the java API that supports commits and rollbacks for the producer.

Has anybody made some experiences with transactions and Kafka and can give me an hint?

like image 914
padmalcom Avatar asked Aug 18 '15 13:08

padmalcom


People also ask

How do transactions work in Kafka?

Transactions in Kafka are designed so that they are mainly handled on the producer/message broker side, rather than the consumer side. The consumer is effectively an idempotent reader, while the producer/coordinator handle the transaction.

What is transaction topic in Kafka?

The transaction log is an internal kafka topic. Each coordinator owns some subset of the partitions in the transaction log, ie. the partitions for which its broker is the leader. Every transactional.id is mapped to a specific partition of the transaction log through a simple hashing function.

Does Kafka support XA transactions?

Any attempt to involve any third-party data sources in the business process is stuck because the Kafka fundamentally does not support XA transactions.

How much data Kafka can handle?

Conclusion: Kafka can handle the volume With 5 brokers it makes autoscaling the Kafka cluster to 4 vCPU and 12 GB memory we are able to sustain 200 million events per hour or 55,000 events per second simple.


3 Answers

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.

[Source]: Please read the wiki for details

like image 55
user2720864 Avatar answered Oct 23 '22 06:10

user2720864


No; Kafka does not support transactions.

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

like image 23
mlg Avatar answered Oct 23 '22 06:10

mlg


Actually, from the last version 0.11.0.0 transactions are supported. See Guarantee unique global transaction for Kafka Producers

like image 3
rh0x Avatar answered Oct 23 '22 06:10

rh0x