You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/09/20 15:08:36 UTC

[rocketmq] branch develop updated: Use StandardCharsets.UTF_8 as default charset of getting bytes when sending example messages (#5140)

This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new a7b2cc367 Use StandardCharsets.UTF_8 as default charset of getting bytes when sending example messages (#5140)
a7b2cc367 is described below

commit a7b2cc3675ce05578f2bdcd350a6f66a51482af0
Author: renyansongno1 <45...@users.noreply.github.com>
AuthorDate: Tue Sep 20 23:08:21 2022 +0800

    Use StandardCharsets.UTF_8 as default charset of getting bytes when sending example messages (#5140)
---
 .../src/main/java/org/apache/rocketmq/example/simple/Producer.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
index 2b838a2eb..920d481b9 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.client.exception.MQClientException;
 import org.apache.rocketmq.client.producer.DefaultMQProducer;
 import org.apache.rocketmq.client.producer.SendResult;
 import org.apache.rocketmq.common.message.Message;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
+import java.nio.charset.StandardCharsets;
 
 public class Producer {
 
@@ -37,14 +37,15 @@ public class Producer {
         //producer.setNamesrvAddr(DEFAULT_NAMESRVADDR);
 
         producer.start();
-        for (int i = 0; i < 128; i++)
+        for (int i = 0; i < 128; i++) {
             try {
-                Message msg = new Message(TOPIC, TAG, "OrderID188", "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+                Message msg = new Message(TOPIC, TAG, "OrderID188", "Hello world".getBytes(StandardCharsets.UTF_8));
                 SendResult sendResult = producer.send(msg);
                 System.out.printf("%s%n", sendResult);
             } catch (Exception e) {
                 e.printStackTrace();
             }
+        }
 
         producer.shutdown();
     }