This is an automated email from the ASF dual-hosted git repository.
liuyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new c0a708aad65 Add producer access mode examples for Java and C++ client.
(#537)
c0a708aad65 is described below
commit c0a708aad65813e767b36aff65f4d443223669d2
Author: Baodi Shi <[email protected]>
AuthorDate: Wed Apr 26 07:20:52 2023 +0800
Add producer access mode examples for Java and C++ client. (#537)
---
docs/client-libraries-producers.md | 49 +++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/docs/client-libraries-producers.md
b/docs/client-libraries-producers.md
index 8a4aaa69181..63fe47a1dfd 100644
--- a/docs/client-libraries-producers.md
+++ b/docs/client-libraries-producers.md
@@ -784,4 +784,51 @@ This example shows how to set the `EnforceUnencrypted`
encryption policy.
</TabItem>
</Tabs>
-````
\ No newline at end of file
+````
+
+## Configure access mode
+
+[Access mode](concepts-clients.md#access-mode) allows applications to require
exclusive producer access on a topic to achieve a "single-writer" situation.
+
+This example shows how to set producer access mode.
+
+````mdx-code-block
+<Tabs groupId="lang-choice"
+ defaultValue="Java"
+ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}>
+<TabItem value="Java">
+
+::: note
+
+This feature is supported in Java client 2.8.0 or later versions.
+
+:::
+
+ ```java
+ Producer<byte[]> producer = client.newProducer()
+ .topic(topic)
+ .accessMode(ProducerAccessMode.Exclusive)
+ .create();
+ ```
+
+ </TabItem>
+
+<TabItem value="C++">
+
+::: note
+
+This feature is supported in C++ client 3.1.0 or later versions.
+
+:::
+
+ ```cpp
+ Producer producer;
+ ProducerConfiguration producerConfiguration;
+ producerConfiguration.setAccessMode(ProducerConfiguration::Exclusive);
+ client.createProducer(topicName, producerConfiguration, producer);
+ ```
+
+ </TabItem>
+
+</Tabs>
+````