You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/10 04:51:12 UTC

[GitHub] [pulsar] tisonkun commented on a diff in pull request #18845: [fix][doc] Avoid refer to deprecated classes

tisonkun commented on code in PR #18845:
URL: https://github.com/apache/pulsar/pull/18845#discussion_r1044985152


##########
site2/website/versioned_docs/version-2.9.x/cookbooks-compaction.md:
##########
@@ -109,40 +109,29 @@ 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;
 
 PulsarClient client = PulsarClient.builder()
         .serviceUrl("pulsar://localhost:6650")
         .build();
 
-Producer<byte[]> compactedTopicProducer = client.newProducer()
+        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();

Review Comment:
   Good catch! Fixing...



##########
site2/website/versioned_docs/version-2.9.x/cookbooks-compaction.md:
##########
@@ -109,40 +109,29 @@ 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;
 
 PulsarClient client = PulsarClient.builder()
         .serviceUrl("pulsar://localhost:6650")
         .build();
 
-Producer<byte[]> compactedTopicProducer = client.newProducer()
+        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();

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org