Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

public class KafkaProducer<K, V> {
    /**
     * Bind producer to an external session. 
     * Lifecycle methods (e.g., beginTransaction) throw IllegalStateException.
     */
    public KafkaProducer(Map<String, Object> configs, TransactionSession session);

    /**
     * Access the session (internal or external). Returns null if non-transactional.
     */
    public TransactionSession transactionSession();
}

```


Backward Compatibility: Constructing a producer with transactional.id in the config works as it does today.

It will internally create a TransactionSession and use its existing methods (initTransactions, beginTransaction, etc.) as convenience wrappers.

...

For KIP-1289 transactional acknowledgments, the share consumer accepts a TransactionSession:


```java```
public class KafkaShareConsumer<K, V> {

    /**

   * Acknowledge records transactionally within the givenprovided session.

    * Sends AddShareAcksToTxn (API 83) + TxnShareAcknowledge (API 84)
* using the session's identity.
*/
 */

    public void acknowledgeTransactionally(

        TransactionSession session,

        Map<TopicPartition, Set<Long>> acknowledgments

    );

}
```

...

3. Proposed Changes

...