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 examples for transactional producer and consumer #22

Merged
merged 4 commits into from
Feb 8, 2021

Conversation

dcrodman
Copy link
Contributor

@dcrodman dcrodman commented Feb 1, 2021

Hi @twmb! I'm implementing a new producer with this library since it seems to have great support for producing messages in transactions and I need exactly-once semantics. I ended up crafting a couple of examples to test things out and figured I might put them out there for the sake of consolidating some of the transaction documentation.

I know the other examples don't use a main package but I found it convenient to be able to run the example as-is so I left it in there. More than happy to make changes to that or any other part of this.

As a side note, if I'm doing anything wrong here I'd really appreciate any feedback or guidance here.

Example output (repeats every 10s):

produced message: batch 0 record 0
produced message: batch 0 record 1
produced message: batch 0 record 2
produced message: batch 0 record 3
produced message: batch 0 record 4
produced message: batch 0 record 5
produced message: batch 0 record 6
produced message: batch 0 record 7
produced message: batch 0 record 8
produced message: batch 0 record 9
consumed record with message: batch 0 record 0
consumed record with message: batch 0 record 1
consumed record with message: batch 0 record 2
consumed record with message: batch 0 record 3
consumed record with message: batch 0 record 4
consumed record with message: batch 0 record 5
consumed record with message: batch 0 record 6
consumed record with message: batch 0 record 7
consumed record with message: batch 0 record 8
consumed record with message: batch 0 record 9

@twmb
Copy link
Owner

twmb commented Feb 3, 2021

Hey there, thanks for the example! I've added a few small comments to clarify some underlying behaviors, but otherwise this generally looks good!

@twmb
Copy link
Owner

twmb commented Feb 8, 2021

Looks great, thank you!

@twmb twmb merged commit c2c014a into twmb:master Feb 8, 2021
@dcrodman dcrodman deleted the dr/transaction-examples branch February 8, 2021 21:20
@dcrodman
Copy link
Contributor Author

dcrodman commented Feb 8, 2021

Thanks for the suggestions and feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants