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

Introduce Kafka::asyncPublish() #312

Merged
merged 16 commits into from
Aug 18, 2024
Merged

Introduce Kafka::asyncPublish() #312

merged 16 commits into from
Aug 18, 2024

Conversation

mateusjunges
Copy link
Owner

@mateusjunges mateusjunges commented Aug 13, 2024

This PR introduces async producers. The producer builder is created when you first call Kafka::asyncPublish. The first message sent will create a producer, which will be stored in memory together with the builder. This means that the same builder/producer will be used during the request, even if you have multiple calls to Kafka::asyncPublish.

With async publishing, the producer will be flushed at the end of your request when the app is terminating, instead of flushing after every single message you send.

Benchmark

Before this PR, it takes ~1512ms to send 1000 messages to a kafka topic.
After this is merged, this time decreases to ~20ms

sash and others added 7 commits August 9, 2024 19:23
…hSend but only once when the application is terminating (#310)

* upd: async production (that has only one flush at the end of the application) [see discussion #309]

* fix: added broker parameter to the facade helper [see discussion #309]

* ref: simplify Builder construct extension [see discussion #309]

---------

Co-authored-by: Alexander (SASh) Alexiev <[email protected]>
@mateusjunges mateusjunges self-assigned this Aug 13, 2024
@mateusjunges mateusjunges changed the title IntroduceKafka::asyncPublish() Introduce Kafka::asyncPublish() Aug 13, 2024
@mateusjunges mateusjunges merged commit 0864373 into master Aug 18, 2024
8 checks passed
@mateusjunges mateusjunges deleted the dev branch August 18, 2024 02:57
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