-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
Milestone
Description
In consumer client code ConsumeMessageConcurrentlyService
, there is a scheduled executor used to clean the expired messages(consuming-blocked messages) in ProcessQueue
.
this.cleanExpireMsgExecutors.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
cleanExpireMsg();
}
}, this.defaultMQPushConsumer.getConsumeTimeout(), this.defaultMQPushConsumer.getConsumeTimeout(), TimeUnit.MINUTES);
When using scheduleAtFixedRate
, once a thread throws an exception, it will not continue to execute the following threads. So the Runnable must be surrounded by try-catch.
Since the scheduleAtFixedRate without try-catch, the cleanExpireMsg
thread may abnormally exit and never be executed again, which may cause the consuming-blocked message always stay in ProcessQueue
, resulting in the consume offset get stuck. (We have actually met this problem in production environment.)