Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ikilobyte committed Oct 25, 2023
1 parent ed01e52 commit bcfd6ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ for ($i = 0; $i < 10; $i++) {
]);
}

// Send Batch message
$messages = [];
for ($i = 0;$i < 10;$i++) {
$messages[] = json_encode([
'id' => $i,
'now' => date('Y-m-d H:i:s')
]);
}

$messageID = $producer->send($messages);
echo "batch message id ${messageID}\n";

// close
$producer->close();

Expand Down Expand Up @@ -187,6 +199,20 @@ while (true) {
$consumer->close();
```

> 批量接收消息
- 只有当生产者批量发送消息时,才能接收到批量消息。

```php
$messages = $consumer->batchReceive();
foreach ($messages as $message) {
// ...

// Ack
$consumer->ack($message);
}
```

> 订阅多个主题
```php
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ for ($i = 0; $i < 10; $i++) {
]);
}

// Send Batch message
// The underlying protocol will automatically package these messages into a message and send it to pulsar
$messages = [];
for ($i = 0;$i < 10;$i++) {
$messages[] = json_encode([
'id' => $i,
'now' => date('Y-m-d H:i:s')
]);
}

$messageID = $producer->send($messages);
echo "batch message id ${messageID}\n";

// close
$producer->close();
```
Expand Down Expand Up @@ -189,6 +202,20 @@ while (true) {
$consumer->close();
```

> Receive Batch Message
- Only when the producer sends the message in bulk can the batch message be received.

```php
$messages = $consumer->batchReceive();
foreach ($messages as $message) {
// ...

// Ack
$consumer->ack($message);
}
```

> Subscribe to multiple topics
```php
Expand Down

0 comments on commit bcfd6ba

Please sign in to comment.