Does Shopify/sarama provide an option similar to transactional.id
in JVM API?
The library supports idempotence (Config.Producer.Idemponent
, similar to enable.idempotence
), but I don't understand how to use it without transactional.id
.
Please, correct me if I'm wrong, there is a bit lack of documentation about these options in Sarama. But according to JVM docs, idempotence without the identifier will be limited by a single producer session. In other words, we will loss the guarantee when producer fails and restart.
I found relevant properties in the source code and some tests (for example), but don't understand how to use them externally.
Shopify/sarama Provides Kafka Exactly Once (Idempotency) with idempotent enabled producer. But For that below configuration setup need to be there.
From Shopify/sarama/config.go
In Shopify/sarama How they do this is, There is a
producerEpoch
ID inAsyncProducer
'stransactionManager
. You can refer the file in Shopify/sarama/async_producer.go. This Id initialise with the producer initialisation and increment when successfully producing each message. readbumpEpoch()
function to see that inasync_producer.go
file.This is the sequence id for that producer session with the broker and it is sending with each message. Increment when message published successfully.
Read this example. It describes how idempotence works.
You are correct on producer session fact. That exactly once promised for single producer session. When restating producer just after the sequence failure, there can be a duplicate.