我看到一个队列没有备份的问题,但是消费者实际执行 JMS 消息的时间在创建后 100 到 200 秒之间(通过 JMSTimestamp-CurrentTime 测量)。
队列的流量相当低,每分钟不到 30 条消息。我能够通过重新启动 ActiveMQ 来解决这个问题,之后消息在创建后不到 1 毫秒的时间内启动。
我正在使用 ActiveMQ 5.4.1,在 MDB 中完成的工作的正常总执行时间少于 2 毫秒。在延迟时,ActiveMQ 日志中没有错误消息,CPU 低且内存充足。
似乎消费者正在将消息从队列中拉出,但出于某种原因坐在它们上面。
是否存在一些可能导致此问题的配置问题?
编辑:
我的MDB的第一行如下:
/* Check the time since this message was created versus processed */
try {
long secondsToProcess = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - aMessage.getJMSTimestamp());
if (secondsToProcess > 5) {
log.error("JMS Consumer Start Delay: " + secondsToProcess + " s" + " JMS Message took more then 5 seconds to be processed");
} else {
log.debug("JMS Consumer Start Delay: " + secondsToProcess + " s");
}
} catch (Exception e) {
log.error(e);
}