Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges committed Aug 18, 2024
1 parent 082cf7f commit 2cfa6d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/producing-messages/6-producing-message-batch-to-kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use Junges\Kafka\Message\Message;
$message = new Message(
headers: ['header-key' => 'header-value'],
body: ['key' => 'value'],
key: 'kafka key here'
key: 'kafka key here',
topicName: 'my_topic'
)

$messageBatch = new MessageBatch();
Expand All @@ -35,4 +36,9 @@ $producer = Kafka::publish('broker')
->withConfigOptions(['key' => 'value']);

$producer->sendBatch($messageBatch);
```
```

When producing batch messages, you can specify the topic for each message that you want to publish. If you want to publish all messages in the same topic,
you can use the `onTopic` method on the `MessageBatch` class to specify the topic once for all messages. Please note that
if a message within the batch specifies a topic, we will use that topic to publish the message, instead of the topic defined on the
batch itself.

0 comments on commit 2cfa6d8

Please sign in to comment.