Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add producer transaction API #2295

Merged
merged 2 commits into from
Sep 27, 2022
Merged

Add producer transaction API #2295

merged 2 commits into from
Sep 27, 2022

Conversation

ryarnyah
Copy link
Contributor

@ryarnyah ryarnyah commented Jul 27, 2022

Inspired from #1527
Fix:

Changes:

  • Add BeginTxn/CommitTxn/AbortTxn/AddOffsetsToTxn/AddMessageToTxn to Sync/Async Producer

Example usage: (for more complete examples see examples/txn_producer && examples/exactly_once)

  • Simple transaction producer
config := sarama.NewConfig()
// ...
config.Producer.Transaction.ID = "txn-unique-id"
producer, _ := sarama.NewAsyncProducer(brokers, config)
_ = producer.BeginTxn()
producer.Input() <- &sarama.ProducerMessage{Topic: "test-topic", Key: nil, Value: sarama.StringEncoder("test-value")}
_ = producer.CommitTxn() // Or producer.AbortTxn()

@ghost ghost added the cla-needed label Jul 27, 2022
@ryarnyah ryarnyah force-pushed the feat/producer-tx branch 2 times, most recently from 40dc6a6 to ce3ade0 Compare July 27, 2022 19:19
@ghost ghost removed the cla-needed label Jul 27, 2022
@ryarnyah ryarnyah force-pushed the feat/producer-tx branch 24 times, most recently from 6b5d3d0 to 4120ca2 Compare August 3, 2022 21:32
externalize transaction manager to it's own file

add KAFKA_CFG_TRANSACTION_STATE_LOG_REPLICATION_FACTOR to ensure transaction topic can be in ha mode
@ryarnyah ryarnyah marked this pull request as ready for review August 20, 2022 21:25
@dnwe dnwe added the feat label Sep 27, 2022
Copy link
Collaborator

@dnwe dnwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryarnyah thanks — these changes look good to me, especially with both examples and test coverage

I'll look at migrating some of my own applications over to using the transactional produce to exercise the code

@dnwe dnwe merged commit f16c9d8 into IBM:main Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants