Sending messages in batch improves performance of delivering small messages. Messages of the same batch should have: same topic, same waitStoreMsgOK and no schedule support. You can send messages up to 4MiB at a time, but if you need to send a larger message, it is recommended to divide the larger messages into multiple small messages of no more than 1MiB.
### 1 Send Batch Messages
If you just send messages of no more than 4MiB at a time, it is easy to use batch:
```java
Stringtopic="BatchTest";
List<Message>messages=newArrayList<>();
messages.add(newMessage(topic,"TagA","OrderID001","Hello world 0".getBytes()));
messages.add(newMessage(topic,"TagA","OrderID002","Hello world 1".getBytes()));
messages.add(newMessage(topic,"TagA","OrderID003","Hello world 2".getBytes()));
try{
producer.send(messages);
}catch(Exceptione){
e.printStackTrace();
//handle the error
}
```
### 2 Split into Lists
The complexity only grow when you send large batch and you may not sure if it exceeds the size limit (4MiB). At this time, you’d better split the lists: