Limitations
Only the Remoting SDK is supported. For more information, see the SDK reference overview.
Batch sending supports only normal messages and ordered messages. It does not support scheduled messages or transactional messages.
For ordered messages, all messages in a batch must have the same sharding key property.
The total size of a batch, including all message properties, cannot exceed 4 MB. A single batch can contain a maximum of 4,096 messages.
Batch sending does not support client-side message compression.
Each message, whether in a batch or sent individually, must have a body size greater than 0.
The properties of every message, whether in a batch or sent individually, are validated and must not contain any illegal characters.
Batch consumption is not supported.
Usage
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);
Canal configuration
# For instances that support batch sending, set the flatMessage property to true.
canal.mq.flatMessage = trueMessage transaction count calculation
The message transaction count is calculated using the following formula:
Max{⌈Total Size / 4 KB⌉, Number of Messages}. For example, if you send a batch of 10 messages with a total size of 50 KB, the transaction count is calculated as⌈50 KB / 4 KB⌉ = 13.This count is used for billing and metering and for TPS statistics for rate limiting.