From 445eabc59a12ba9b549365c64e0088f955ea13c3 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 30 Mar 2020 11:13:44 -0400 Subject: [PATCH] Transactional Producer Doc Polishing - explain txId requirements for producer-initiated transactions --- docs/src/main/asciidoc/overview.adoc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/overview.adoc b/docs/src/main/asciidoc/overview.adoc index 0252f7604..8fd02967a 100644 --- a/docs/src/main/asciidoc/overview.adoc +++ b/docs/src/main/asciidoc/overview.adoc @@ -583,10 +583,14 @@ If you wish to use transactions in a source application, or from some arbitrary [source, java] ---- @Bean -public PlatformTransactionManager transactionManager(BinderFactory binders) { +public PlatformTransactionManager transactionManager(BinderFactory binders, + @Value("${unique.tx.id.per.instance}") String txId) { + ProducerFactory pf = ((KafkaMessageChannelBinder) binders.getBinder(null, MessageChannel.class)).getTransactionalProducerFactory(); - return new KafkaTransactionManager<>(pf); + KafkaTransactionManager tm = new KafkaTransactionManager<>(pf); + tm.setTransactionId(txId) + return tm; } ---- ==== @@ -613,6 +617,8 @@ public static class Sender { If you wish to synchronize producer-only transactions with those from some other transaction manager, use a `ChainedTransactionManager`. +IMPORTANT: If you deploy multiple instances of your application, each instance needs a unique `transactionIdPrefix`. + [[kafka-error-channels]] === Error Channels