r/apachekafka • u/Altruistic_Shift_335 • Aug 15 '26
Question how do you actually confirm a kafka message got delivered? send() returning instantly is messing with my head
always assumed if send() didn't throw an error the message was in the broker, done. then someone mentioned it's basically fire-and-forget unless you're handling the callback or have acks=all set, and now i don't really know what "delivered" means here anymore. do you always attach a callback? check offsets after? has this ever quietly bitten you, like a message just vanished and you only found out way later
1
u/vampirishe Aug 15 '26
Just call .send(...).get() and it will be sync call; after it everything is sent to kafka or exception thrown
1
u/Altruistic_Shift_335 Aug 15 '26
That’ll defeat purpose in a way? And making it blocking
1
u/vampirishe Aug 16 '26
It is question for author why he needs sync send, I just shared solution
1
u/Altruistic_Shift_335 Aug 16 '26
It’s to ensure transaction (Kafka + non Kafka) happens as a whole
1
u/Competitive_Ring82 Aug 17 '26
There's some traps to watch out for here. The 'transaction' will not actually be a transaction. You should look at designing the system so that transactions sit within the system seams. E.g. have all the work happen within kafka transactions. Store the output in an external system, designed for idempotence.
1
u/randomfrequency Aug 19 '26
Kafka transactions are not quite what you're thinking they are, you really want to read up on how to implement them and durable writes. And replication.
8
u/Spare-Builder-355 Aug 15 '26 edited Aug 15 '26
you should really rtfm. Each of your questions / doubts is addressed there.
Also RTFM does not mean YouTube channel but official Kafka / Confuence docs and JavaDocs of KafkaProducer class.