This is an automated email from the ASF dual-hosted git repository.

zhfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 8e781c8248b Add doc for kafka transaction (#7577)
8e781c8248b is described below

commit 8e781c8248b8e4cfa5976f6187bfbb3cd5f2a6d7
Author: Amos Feng <[email protected]>
AuthorDate: Tue May 10 16:40:21 2022 +0800

    Add doc for kafka transaction (#7577)
---
 components/camel-kafka/src/main/docs/kafka-component.adoc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/components/camel-kafka/src/main/docs/kafka-component.adoc 
b/components/camel-kafka/src/main/docs/kafka-component.adoc
index a56ef6e2013..135b0a2f7d1 100644
--- a/components/camel-kafka/src/main/docs/kafka-component.adoc
+++ b/components/camel-kafka/src/main/docs/kafka-component.adoc
@@ -423,5 +423,16 @@ from("kafka:my_topic?headerFilterStrategy=#myStrategy")
 
 `myStrategy` object should be subclass of `HeaderFilterStrategy` and must be 
placed in the Camel registry, either manually or by registration as a bean in 
Spring/Blueprint, as it is `CamelContext` aware.
 
+== Kafka Transaction
+
+You need to add `transactional.id`, `enable.idempotence` and `retries` in 
`additional-properties` to enable kafka transaction with the producer.
+[source,java]
+----
+from("direct:transaction")
+.to("kafka:my_topic?additional-properties[transactional.id]=1234&additional-properties[enable.idempotence]=true&additional-properties[retries]=5");
+----
+At the end of exchange routing, the kafka producer would commit the 
transaction or abort it if there is an Exception throwing or the exchange is 
`RollbackOnly`. Since Kafka does not support transactions in multi threads, it 
will throw `ProducerFencedException` if there is another producer with the same 
`transaction.id` to make the transactional request.
+
+It would work with JTA `camel-jta` by using `transacted()` and if it involves 
some resources (SQL or JMS) which supports XA, then they would work in tandem, 
where they both will either commit or rollback at the end of the exchange 
routing. In some cases, if the JTA transaction manager fails to commit (during 
the 2PC processing), but kafka transaction has been committed before and there 
is no chance to rollback the changes since the kafka transaction does not 
support JTA/XA spec. There is [...]
 
 include::spring-boot:partial$starter.adoc[]

Reply via email to