This is an automated email from the ASF dual-hosted git repository.
junma pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new c6edd75317f Update cookbooks-message-queue.md (#17278)
c6edd75317f is described below
commit c6edd75317fb50f206a067b3ef761abbb4a2828b
Author: momo-jun <[email protected]>
AuthorDate: Fri Sep 16 12:58:42 2022 +0800
Update cookbooks-message-queue.md (#17278)
---
site2/docs/cookbooks-message-queue.md | 59 ++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 19 deletions(-)
diff --git a/site2/docs/cookbooks-message-queue.md
b/site2/docs/cookbooks-message-queue.md
index 50d1b67eabd..fca9b7218e2 100644
--- a/site2/docs/cookbooks-message-queue.md
+++ b/site2/docs/cookbooks-message-queue.md
@@ -1,31 +1,52 @@
---
id: cookbooks-message-queue
-title: Using Pulsar as a message queue
+title: Use Pulsar as a message queue
sidebar_label: "Message queue"
---
-Message queues are essential components of many large-scale data
architectures. If every single work object that passes through your system
absolutely *must* be processed despite the slowness or downright failure of
this or that system component, there's a good chance that you'll need a message
queue to step in and ensure that unprocessed data is retained---with correct
ordering---until the required actions are taken.
+````mdx-code-block
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+````
+
+Message queues are essential components of many large-scale data
architectures. If every single work object that passes through your system
absolutely *must* be processed in spite of the slowness or downright failure of
this or that system component, there's a good chance that you'll need a message
queue to step in and ensure that unprocessed data is retained---with correct
ordering---until the required actions are taken.
Pulsar is a great choice for a message queue because:
* it was built with [persistent message
storage](concepts-architecture-overview.md#persistent-storage) in mind
* it offers automatic load balancing across
[consumers](reference-terminology.md#consumer) for messages on a topic (or
custom load balancing if you wish)
-> You can use the same Pulsar installation to act as a real-time message bus
and as a message queue if you wish (or just one or the other). You can set
aside some topics for real-time purposes and other topics for message queue
purposes (or use specific namespaces for either purpose if you wish).
+:::tip
+
+You can use the same Pulsar installation to act as a real-time message bus and
as a message queue if you wish (or just one or the other). You can set aside
some topics for real-time purposes and other topics for message queue purposes
(or use specific namespaces for either purpose if you wish).
+
+:::
+
+## Client configuration changes
+
+To use a Pulsar [topic](reference-terminology.md#topic) as a message queue,
you should distribute the receiver load on that topic across several consumers
(the optimal number of consumers depends on the load).
+Each consumer must establish a [shared
subscription](concepts-messaging.md#shared) and use the same subscription name
as the other consumers (otherwise the subscription is not shared and the
consumers can't act as a processing ensemble).
-# Client configuration changes
+If you'd like to have tight control over message dispatching across consumers,
set the consumers' **receiver queue** size very low (potentially even to 0 if
necessary). Each consumer has a receiver queue that determines how many
messages the consumer attempts to fetch at a time. For example, a receiver
queue of 1000 (the default) means that the consumer attempts to process 1000
messages from the topic's backlog upon connection. Setting the receiver queue
to 0 essentially means ensuring t [...]
-To use a Pulsar [topic](reference-terminology.md#topic) as a message queue,
you should distribute the receiver load on that topic across several consumers
(the optimal number of consumers will depend on the load). Each consumer must:
+:::tip
-* Establish a [shared subscription](concepts-messaging.md#shared) and use the
same subscription name as the other consumers (otherwise the subscription is
not shared and the consumers can't act as a processing ensemble)
-* If you'd like to have tight control over message dispatching across
consumers, set the consumers' **receiver queue** size very low (potentially
even to 0 if necessary). Each Pulsar
[consumer](reference-terminology.md#consumer) has a receiver queue that
determines how many messages the consumer will attempt to fetch at a time. A
receiver queue of 1000 (the default), for example, means that the consumer will
attempt to process 1000 messages from the topic's backlog upon connection.
Setti [...]
+The receiver queue size of a partitioned topic consumer adopts the minimum one
of the following two values:
+* `receiver_queue_size`
+* `max_total_receiver_queue_size_across_partitions`/`NumPartitions`
- The downside to restricting the receiver queue size of consumers is that
that limits the potential throughput of those consumers and cannot be used with
[partitioned topics](reference-terminology.md#partitioned-topic). Whether the
performance/control trade-off is worthwhile will depend on your use case.
+:::
-## Java clients
+## Example
-Here's an example Java consumer configuration that uses a shared subscription:
+Here's an example that uses a shared subscription.
+
+````mdx-code-block
+<Tabs groupId="lang-choice"
+ defaultValue="Java"
+
values={[{"label":"Java","value":"Java"},{"label":"Python","value":"Python"},{"label":"C++","value":"C++"},{"label":"Go","value":"Go"}]}>
+<TabItem value="Java">
```java
import org.apache.pulsar.client.api.Consumer;
@@ -49,9 +70,8 @@ Consumer consumer = client.newConsumer()
.subscribe();
```
-## Python clients
-
-Here's an example Python consumer configuration that uses a shared
subscription:
+</TabItem>
+<TabItem value="Python">
```python
from pulsar import Client, ConsumerType
@@ -69,9 +89,8 @@ consumer = client.subscribe(
consumer_type=ConsumerType.Shared)
```
-## C++ clients
-
-Here's an example C++ consumer configuration that uses a shared subscription:
+</TabItem>
+<TabItem value="C++">
```cpp
#include <pulsar/Client.h>
@@ -92,9 +111,8 @@ Consumer consumer;
Result result = client.subscribe(topic, subscription, consumerConfig,
consumer);
```
-## Go clients
-
-Here is an example of a Go consumer configuration that uses a shared
subscription:
+</TabItem>
+<TabItem value="Go">
```go
import "github.com/apache/pulsar-client-go/pulsar"
@@ -116,3 +134,6 @@ if err != nil {
}
```
+</TabItem>
+</Tabs>
+````
\ No newline at end of file