You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/29 13:56:43 UTC

[GitHub] [rocketmq-site] tsunghanjacktsai commented on a diff in pull request #164: New official website

tsunghanjacktsai commented on code in PR #164:
URL: https://github.com/apache/rocketmq-site/pull/164#discussion_r933293162


##########
docs/09-英文/02-Producer/08message4.md:
##########
@@ -0,0 +1,29 @@
+# Batch Message Sending
+
+In the case of certain requirements on throughput, Apache RocketMQ can group messages into batches and send them. The approach can increase throughput rate and decrease the times of calls of API and network calls.
+
+![batch](../../picture/batch.png)
+
+```javascript {10,11,12,13}
+public class SimpleBatchProducer {
+
+    public static void main(String[] args) throws Exception {
+        DefaultMQProducer producer = new DefaultMQProducer("BatchProducerGroupName");
+        producer.start();
+
+        //If you just send messages of no more than 1MiB at a time, it is easy to use batch
+        //Messages of the same batch should have: same topic, same waitStoreMsgOK and no schedule support
+        String topic = "BatchTest";
+        List<Message> messages = new ArrayList<>();
+        messages.add(new Message(topic, "Tag", "OrderID001", "Hello world 0".getBytes()));
+        messages.add(new Message(topic, "Tag", "OrderID002", "Hello world 1".getBytes()));
+        messages.add(new Message(topic, "Tag", "OrderID003", "Hello world 2".getBytes()));
+
+        producer.send(messages);
+    }
+}
+```
+
+:::note
+This call is very simple, packaging the message as `Collection<Message> msgs` and passing it into the method as a parameter. Here are two points to notice. At first, the size of the batch message cannot exceed 1 MiB, otherwise, it needs to be split. Secondly, the topic of the message in the same batch must be the same.

Review Comment:
   > This call is very simple, packaging the message as `Collection<Message> msgs` and passing it into the method as a parameter. Here are two points to notice. At first, the size of the batch message cannot exceed 1 MiB, otherwise, it needs to be split. Secondly, the topic of the message in the same batch must be the same.
   
   Make a small change would sound better:
   
   > The call here is simple, where it packages the message as `Collection<Message> msgs` and passes it into the method as a parameter. There are two things to note here. First of all, the size of the batch message cannot exceed 1 MiB, otherwise, it needs to be split. Secondly, the message topic within the same batch must be identical.



##########
docs/09-英文/02-Producer/08message4.md:
##########
@@ -0,0 +1,29 @@
+# Batch Message Sending
+
+In the case of certain requirements on throughput, Apache RocketMQ can group messages into batches and send them. The approach can increase throughput rate and decrease the times of calls of API and network calls.

Review Comment:
   > In the case of certain requirements on throughput, Apache RocketMQ can group messages into batches and send them. The approach can increase throughput rate and decrease the times of calls of API and network calls.
   
   Would better rephrase to:
   
   > In the case of certain requirements on throughput, Apache RocketMQ can send messages after grouping them into batches. The approach is able to increase throughput and decrease the times of API and network calls.



-- 
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: dev-unsubscribe@rocketmq.apache.org

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