Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add producer access mode examples for Java and C++ client. #537

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion docs/client-libraries-producers.md
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,51 @@ This example shows how to set the `EnforceUnencrypted` encryption policy.

</TabItem>
</Tabs>
````
````

## 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>
````