From 2da56117b7b13f5e92b4b3e17aa6daba3634fa95 Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Sun, 18 Aug 2024 00:12:34 -0300 Subject: [PATCH] Add docs --- docs/producing-messages/1-producing-messages.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/producing-messages/1-producing-messages.md b/docs/producing-messages/1-producing-messages.md index b9da13fa..0a1096c0 100644 --- a/docs/producing-messages/1-producing-messages.md +++ b/docs/producing-messages/1-producing-messages.md @@ -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. \ No newline at end of file +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') +``` \ No newline at end of file