Question

I'm seeing a problem where a Queue is not backed up however the time for the consumer to actually execute the JMS message is between 100 - 200 seconds from creation (as measured via the JMSTimestamp-CurrentTime).

The flow was fairly low to the queue, less then 30 messages a minute. I was able to resolve the issue by restarting ActiveMQ, after which messages were being started on less then 1ms from when they were created.

I'm using ActiveMQ 5.4.1 and the normal total execution time for the work being done in the MDB is less then 2ms. At the time of the delay, there were no error messages in the ActiveMQ log, CPU was low and had plenty of memory.

It seems like the consumer is pulling the message off the queue, but sitting on them for some reason.

Is there some configuration issue which could be causing this issue?

Edit:

The first line of my MDB is as follows:

 /* 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);
        }
Was it helpful?

Solution 2

As it turns out, ActiveMQ was behaving just fine, my workers were taking too long hence backing up the queue. The code in my question allowed me to see that.

OTHER TIPS

How certain are you that the consumer is pulling the message off the queue immediately? ActiveMQ provides the JMSActiveMQBrokerInTime and JMSActiveMQBrokerOutTime properties you can use to confirm this (see ActiveMQ message properties).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top