Using transactional producer without transactions for fencing in k8s

Is it possible to use a transactional producer without transactions? The goal is to have the producer get fenced if another (newer) instance pops up on another k8s pod. But with this particular producer, I won’t ever have a transaction with more than one related message, so I wouldn’t want the overhead of having to call commit() every time I produce with it.

Alternatively, I could have a transactional producer, and do things like:

producer.send(oneRecord, myCallback);
But there would be multiple threads producing at once.

Would all of those commit()'s cause a big performance hit?

Here’s another question—can multiple transactions be batched into one network request from the producer to the broker(s)?

Edit: it turns out they can’t, purusuant to:–
> This method will flush any unsent records before actually committing the transaction.

Sounds like you want a distributed lock, not just a transaction boundary

A distributed lock would work, but introducing any systems outside of Kafka is not an option.


That’s not in Kafka anymore :wink:

The transactional producer solves a problem that is a superset of distributed lock on being able to produce with a certain ID. It just may be overkill