In my web app, I submit a runable instance to the ScheduledExecutorService. In the runable instance, I receive message from IBM MQ by use receiveNoWait mehod and the session is in CLIENT_ACKNOWLEDGE mode. When I invoke the shutdownNow method of ScheduledExecutorService, the receive method sometimes loses a message without invoking acknowledge method. Is there some suggestion for me?
Here is the code to receive a message.
try {
when the ScheduledExecutorService shutdownNow ,I can only see the first loginfo without any exception.logger.info("获取消息");
Message msg = consumer.receiveNoWait();
logger.info("获取消息成功");
return msg;
} catch (Throwable e) {
logger.error("处理数据的时候出现异常", e);
return null;
}