How to set the message load balance consumption in RocketMQ with two client?

71 Views Asked by At

There are two Rocket MQ clients, both of which belong to the same consumption group. How to set the message load balance consumption? It seems that one client has more consumption messages and the other has less, and the consumption is uneven.

2

There are 2 best solutions below

0
Li Zhanhui On

This link should clarify your question.

0
Francis Lee On
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1");
consumer.subscribe("TopicTest", "*");

// MessageModel.CLUSTERING means all consumers consume load-balancely
// MessageModel.BROADCASTING means every consumer instance will consume all messages
consumer.setMessageModel(MessageModel.CLUSTERING);