This is an automated email from the ASF dual-hosted git repository. penghui 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 f49d094 [Doc] Add guides for producer access mode (#9938) f49d094 is described below commit f49d094ca698792740b4d522b25a17000838fdab Author: Yu Liu <50226895+anonymit...@users.noreply.github.com> AuthorDate: Thu Mar 18 10:29:51 2021 +0800 [Doc] Add guides for producer access mode (#9938) --- site2/docs/concepts-messaging.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/site2/docs/concepts-messaging.md b/site2/docs/concepts-messaging.md index 3a8f6a0..cad328f 100644 --- a/site2/docs/concepts-messaging.md +++ b/site2/docs/concepts-messaging.md @@ -53,6 +53,25 @@ Producers send messages to brokers synchronously (sync) or asynchronously (async | Sync send | The producer waits for an acknowledgement from the broker after sending every message. If the acknowledgment is not received, the producer treats the sending operation as a failure. | | Async send | The producer puts a message in a blocking queue and returns immediately. The client library sends the message to the broker in the background. If the queue is full (you can [configure](reference-configuration.md#broker) the maximum size), the producer is blocked or fails immediately when calling the API, depending on arguments passed to the producer. | +### Access mode + +You can have different types of access modes on topics for producers. + +|Access mode | Description +|---|--- +`Shared`|Multiple producers can publish on a topic. <br><br>This is the **default** setting. +`Exclusive`|Only one producer can publish on a topic. <br><br>If there is already a producer connected, other producers trying to publish on this topic get errors immediately.<br><br>The “old” producer is evicted and a “new” producer is selected to be the next exclusive producer if the “old” producer experiences a network partition with the broker. +`WaitForExclusive`|If there is already a producer connected, the producer creation is pending (rather than timing out) until the producer gets the `Exclusive` access.<br><br>The producer that succeeds in becoming the exclusive one is treated as the leader. Consequently, if you want to implement the leader election scheme for your application, you can use this access mode. + +> **Note** +> +> Once an application creates a producer with the `Exclusive` or `WaitForExclusive` access mode successfully, the instance of the application is guaranteed to be the **only one writer** on the topic. Other producers trying to produce on this topic get errors immediately or have to wait until they get the `Exclusive` access. +> +> For more information, see [PIP 68: Exclusive Producer](https://github.com/apache/pulsar/wiki/PIP-68:-Exclusive-Producer). + +You can set producer access mode through Java Client API. For more information, see `ProducerAccessMode` in [ProducerBuilder.java](https://github.com/apache/pulsar/blob/fc5768ca3bbf92815d142fe30e6bfad70a1b4fc6/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerBuilder.java). + + ### Compression You can compress messages published by producers during transportation. Pulsar currently supports the following types of compression: