Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges committed Aug 18, 2024
1 parent c75463f commit 2da5611
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/producing-messages/1-producing-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ Kafka::asyncPublish('broker')->onTopic('topic-name')
```

The main difference is that the Async Producer is a singleton and will only flush the producer when the application is shutting down, instead of after each send or batch send.
This reduces the overhead when you want to send a lot of messages in your request handlers.
This reduces the overhead when you want to send a lot of messages in your request handlers.

When doing async publishing, the builder is stored in memory during the entire request. If you need to use a fresh producer, you may use the `fresh` method
available on the `Kafka` facade (added in v2.2.0). This method will return a fresh Kafka Manager, which you can use to produce messages with a newly created producer builder.


```php
use Junges\Kafka\Facades\Kafka;

Kafka::fresh()
->asyncPublish('broker')
->onTopic('topic-name')
```

0 comments on commit 2da5611

Please sign in to comment.