After send message to the RocketMQ 4.8, I found the consumer only consumed part of the queue. This is the RocketMQ consumer code looks like:
public void appConsumer(Long appId, List<String> topics) throws MQClientException {
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(appId.toString());
RocketMQConfigDTO rocketMQConfigDTO = MqConfigHandler.MQConfig();
consumer.setNamesrvAddr(rocketMQConfigDTO.getHost());
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setMaxReconsumeTimes(rocketMQConfigDTO.getMaxReconsumeTimes());
consumer.setConsumeThreadMin(rocketMQConfigDTO.getConsumeThreadMin());
consumer.setConsumeThreadMax(rocketMQConfigDTO.getConsumeThreadMax());
consumer.setConsumeMessageBatchMaxSize(rocketMQConfigDTO.getConsumeMessageBatchMaxSize());
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
for (String topic : topics) {
consumer.subscribe(topic, "*");
}
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
Callable<ConsumeConcurrentlyStatus> task = new Callable<ConsumeConcurrentlyStatus>() {
@Override
public ConsumeConcurrentlyStatus call() throws Exception {
return handleMessage(msgs, context,appId);
}
};
asyncService.submit(task);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
consumer.start();
eventConsumers.put(appId, consumer);
}
When I access to the RocketMQ dashboard, I found the consumer only consumed part of the queue in the same broker:
The queue 0 and 1's message were not consumed by the consumer. Why did this happen? What should I do to fixed this problem? Why did the consumer only consume messages 3 and 4?