Skip to content

Commit

Permalink
[fix][doc] Avoid refer to deprecated classes (#18845)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Dec 10, 2022
1 parent 71bf3b2 commit 1b5722d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 72 deletions.
23 changes: 8 additions & 15 deletions site2/docs/cookbooks-compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,16 @@ Consumer<byte[]> compactedTopicConsumer = client.newConsumer()
As mentioned above, topic compaction in Pulsar works on a *per-key basis*. That means that messages that you produce on compacted topics need to have keys (the content of the key will depend on your use case). Messages that don't have keys will be ignored by the compaction process. Here's an example Pulsar message with a key:

```java
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.apache.pulsar.client.api.TypedMessageBuilder;

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();
TypedMessageBuilder<byte[]> msg = producer.newMessage()
.key("some-key")
.value(someByteArray);
```

The example below shows a message with a key being produced on a compacted Pulsar topic:

```java
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;

Expand All @@ -117,11 +113,8 @@ Producer<byte[]> compactedTopicProducer = client.newProducer()
.topic("some-compacted-topic")
.create();

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

compactedTopicProducer.send(msg);
compactedTopicProducer.newMessage()
.key("some-key")
.value(someByteArray)
.send();
```

Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,16 @@ Consumer<byte[]> compactedTopicConsumer = client.newConsumer()
As mentioned above, topic compaction in Pulsar works on a *per-key basis*. That means that messages that you produce on compacted topics need to have keys (the content of the key will depend on your use case). Messages that don't have keys will be ignored by the compaction process. Here's an example Pulsar message with a key:

```java
import org.apache.pulsar.client.api.TypedMessageBuilder;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

TypedMessageBuilder<byte[]> msg = producer.newMessage()
.key("some-key")
.value(someByteArray);
```

The example below shows a message with a key being produced on a compacted Pulsar topic:

```java

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;

Expand All @@ -137,12 +130,8 @@ Producer<byte[]> compactedTopicProducer = client.newProducer()
.topic("some-compacted-topic")
.create();

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

compactedTopicProducer.send(msg);

compactedTopicProducer.newMessage()
.key("some-key")
.value(someByteArray)
.send();
```

27 changes: 8 additions & 19 deletions site2/website/versioned_docs/version-2.8.x/cookbooks-compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,16 @@ Consumer<byte[]> compactedTopicConsumer = client.newConsumer()
As mentioned above, topic compaction in Pulsar works on a *per-key basis*. That means that messages that you produce on compacted topics need to have keys (the content of the key will depend on your use case). Messages that don't have keys will be ignored by the compaction process. Here's an example Pulsar message with a key:

```java
import org.apache.pulsar.client.api.TypedMessageBuilder;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

TypedMessageBuilder<byte[]> msg = producer.newMessage()
.key("some-key")
.value(someByteArray);
```

The example below shows a message with a key being produced on a compacted Pulsar topic:

```java

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;

Expand All @@ -137,12 +130,8 @@ Producer<byte[]> compactedTopicProducer = client.newProducer()
.topic("some-compacted-topic")
.create();

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

compactedTopicProducer.send(msg);

compactedTopicProducer.newMessage()
.key("some-key")
.value(someByteArray)
.send();
```

27 changes: 8 additions & 19 deletions site2/website/versioned_docs/version-2.9.x/cookbooks-compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,16 @@ Consumer<byte[]> compactedTopicConsumer = client.newConsumer()
As mentioned above, topic compaction in Pulsar works on a *per-key basis*. That means that messages that you produce on compacted topics need to have keys (the content of the key will depend on your use case). Messages that don't have keys will be ignored by the compaction process. Here's an example Pulsar message with a key:

```java
import org.apache.pulsar.client.api.TypedMessageBuilder;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

TypedMessageBuilder<byte[]> msg = producer.newMessage()
.key("some-key")
.value(someByteArray);
```

The example below shows a message with a key being produced on a compacted Pulsar topic:

```java

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;

Expand All @@ -137,12 +130,8 @@ Producer<byte[]> compactedTopicProducer = client.newProducer()
.topic("some-compacted-topic")
.create();

Message<byte[]> msg = MessageBuilder.create()
.setContent(someByteArray)
.setKey("some-key")
.build();

compactedTopicProducer.send(msg);

compactedTopicProducer.newMessage()
.key("some-key")
.value(someByteArray)
.send();
```

0 comments on commit 1b5722d

Please sign in to comment.