You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Tim Cuthbertson (JIRA)" <ji...@apache.org> on 2017/11/28 03:45:00 UTC

[jira] [Created] (KAFKA-6278) Allow multiple concurrent transactions on a single producer

Tim Cuthbertson created KAFKA-6278:
--------------------------------------

             Summary: Allow multiple concurrent transactions on a single producer
                 Key: KAFKA-6278
                 URL: https://issues.apache.org/jira/browse/KAFKA-6278
             Project: Kafka
          Issue Type: Improvement
            Reporter: Tim Cuthbertson


It's recommended to share a producer between threads, because it's likely faster / cheaper.

However with the transactional API there's a big caveat. If you're using transactions, every message sent to a given producer instance will be considered part of the "active transaction" regardless of what thread it came from. Furthermore, if two threads want to use transactions on a shared producer instance, it (probably) won't work.

Possible fix: add an API which exposes the transaction ID to the user, instead of making it internal state of the producer. e.g.:

{noformat}
Transaction tx = producer.beginTransaction()
producer.send(tx, message)
producer.commitTransaction(tx)
{noformat}

That way, it's explicit which transaction a message will be part of, rather than the current state which is "the open transaction, which may have been opened by an unrelated thread".

See also initial discussion on slack: https://confluentcommunity.slack.com/archives/C488525JT/p1511739734000012



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)