Rocketmq:MQBrokerException: CODE: 2 DESC: [TIMEOUT_CLEAN_QUEUE]

匿名 (未验证) 提交于 2019-12-03 09:14:57

问题:

when i send message to broker,this exception occasionally occurs.

MQBrokerException: CODE: 2  DESC: [TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while 

This means broker is too busy(when tps>1,5000) to handle so many sending message request. What would be the most impossible reason to cause this? Disk ,cpu or other things? How can i fix it?

回答1:

There are many possible ways.

The root cause is that, there are some messages has waited for long time and no worker thread processes them, rocketmq will trigger the fast failure.

So the below is the cause:

  1. Too many thread are working and they are working very slow to process storing message which makes the cache request is timeout.

  2. The jobs it self cost a long time to process for message storing.

This may be because of:

2.1 Storing message is busy, especially when SYNC_FLUSH is used.

2.2 Syncing message to slave takes long when SYNC_MASTER is used.



回答2:

In /broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java you can see:

final long behind = System.currentTimeMillis() - rt.getCreateTimestamp(); if (behind >= this.brokerController.getBrokerConfig().getWaitTimeMillsInSendQueue()) {   if (this.brokerController.getSendThreadPoolQueue().remove(runnable)) {     rt.setStopRun(true);     rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", behind, this.brokerController.getSendThreadPoolQueue().size()));   } } 

In common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java, getWaitTimeMillsInSendQueue() method returns

public long getWaitTimeMillsInSendQueue() {     return waitTimeMillsInSendQueue; } 

The default value of waitTimeMillsInSendQueue is 200, thus you can just set it bigger to make the queue waiting for longer time. But if you wanna solve the problem completely, you should follow Jaskey's advice and check your code.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!