henrypoter edited a comment on issue #2127: URL: https://github.com/apache/rocketmq/issues/2127#issuecomment-655238278
> > Testcase to reproduce the problem > > [LitePullConsumerSubscribe3.java.txt](https://github.com/apache/rocketmq/files/4856365/LitePullConsumerSubscribe3.java.txt) > > When we call litePullConsumer.setMessageQueueListener(mql) the consumer cannot poll( ) messages from broker. > > Thanks for your details about this issue, and I read your code listed above, Rocketmq's subscribe() mode does not support custom MessageQueueListener, because in subscribe mode, pull consumer will automatically do load balancing. If you change this, it will not work. If you don't want rocketmq to manage load balancing, assign() mode will be a better choice. > > But this setMessageQueueListener() is really best to be hidden from users, are you willing to submit a PR to optimize it? I think the MessageQueueListener should be expose to the application developer. I don't want to manage queue rebalance, but I want to know the queue rebalance event. The custom messageQueueListener is called by RebalanceLitePullImpl.messageQueueChanged() not by DefaultLitePullConsumerImpl. ``` public class RebalanceLitePullImpl extends RebalanceImpl { private final DefaultLitePullConsumerImpl litePullConsumerImpl; //.... @Override public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) { MessageQueueListener messageQueueListener = this.litePullConsumerImpl.getDefaultLitePullConsumer().getMessageQueueListener(); if (messageQueueListener != null) { try { messageQueueListener.messageQueueChanged(topic, mqAll, mqDivided); } catch (Throwable e) { log.error("messageQueueChanged exception", e); } } } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
