[ https://issues.apache.org/jira/browse/KAFKA-6278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chiang updated KAFKA-6278: ------------------------------ Component/s: producer > 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 > Components: producer > Reporter: Tim Cuthbertson > Priority: Major > > 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 (v7.6.3#76005)