And is it possible to write to different topics in a transaction?
The Transactional Producer allows to send data to multiple partitions and guarantees all these writes are either committed or discarded. This is done by grouping multiple calls to send()
(and optionally sendOffsetsToTransaction()
) into a transaction.
Once a transaction is started, you can call commitTransaction()
or abortTransaction()
to complete it.
Consumers configured with isolation.level=read_committed
will not receive messages from aborted transactions.
For more details, check the Message Delivery Semantics section in the docs