You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by TiredAndEmotional <st...@yahoo.co.uk> on 2007/07/04 12:50:47 UTC

Blocking consumers not consuming immediately

Hi,

A brief outline of my set up: 5 dual core machines, one running activemq and
a message producer communicating via a queue with 8 consumers spread across
the other 4 machines. 2 classes of message, 2 of the consumers have
selectors set so that they only select one class of message, the other 6
accept either class of message. Consumption of messages of the selected
class takes approximately 0.1 seconds, consumption of the other class takes
approximately 7 seconds. Message consumption is single threaded on each
consumer, and more or less completely chews up all of a single core's
processing time. 

The loop to consume and process messages is as follows, i.e. the consumer
blocks until it receives a message:

while(keepLooping){
			try{
				message=consumer.receive();
			}catch(JMSException e){
				logger.warn("Problem with Node MessageConsumer.receive().", e);
				sleep(1000);
				continue;
			}			
			//Check message isn't null
			if(message==null){//Can this ever occur?
				sleep(1000);
				continue;
			}
			//Unwrap message
			try{
				m=(ServerMessage)(((ObjectMessage)message).getObject());
			}catch (Exception e){
				logger.info("Failed to extract ServerMessage from "+m+". Message
discarded.");
				continue;
			}
			//Process message
			process(m);
		}//end while(keepLooping)

My problem is that when I look at the status of the queue on jconsole, often
there will be a few (i.e. 1 to 5) messages on the queue whilst many of the
consumers aren't doing anything. Messages are small, on the order of 1-2kb
at most. I changed the prefetch value to 1 for the generic consumers and 3
for the selector consumers, but this does not seem to have fixed the
behaviour. The broker has enqueued/dequeued approximately 340000 messages at
this point in time. Consumers have been restarted a number of times,
including very recently, and this has not affected the behaviour. 

To give an idea of the size of delays, sometimes messages are received by a
consumer 2 minutes or more after they have been sent, when it is clear that
the total amount of processing time required for all messages sent is much,
much, much less than the consumer time available, i.e. there is no load
explanation for the delay. In particular the queue never grew to more than 4
or 5 pending messages in this 2 minute period, hence the greatest possible
load delay would have been 10 seconds rather than 2 minutes.

Does anyone have any ideas as to what might be causing this?

Many thanks for your responses in advance.

Best Regards,

Steve Siller
-- 
View this message in context: http://www.nabble.com/Blocking-consumers-not-consuming-immediately-tf4023758s2354.html#a11428816
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Blocking consumers not consuming immediately

Posted by James Strachan <ja...@gmail.com>.
Could you try 4.1.1? There were a large number of bug fixes in there;
I seem to remember some glitch which would cause messages to stick
around on the queue (requiring a bounce of the broker to get them off
again).


On 7/6/07, TiredAndEmotional <st...@yahoo.co.uk> wrote:
>
>
>
> James.Strachan wrote:
> >
> > Which version are you using?
> >
>
> I'm using version 4.1. Also, except where noted in my original post, all
> broker parameters are set to their default (i.e. all bar prefetch....all
> queues are NON_PERSISTANT). Apart from the connections and queue mentioned,
> there are another 12 connections to the broker 5 or 6 queues and a topic,
> but these only send/receive messages irregularly and the workflows involved
> are trivial. The machine on which the broker resides never uses more than 2
> or 3% of CPU resources.
>
> Many thanks for the response. Apologies for forgetting the most important
> piece of information!
>
>
> --
> View this message in context: http://www.nabble.com/Blocking-consumers-not-consuming-immediately-tf4023758s2354.html#a11459288
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Re: Blocking consumers not consuming immediately

Posted by TiredAndEmotional <st...@yahoo.co.uk>.


James.Strachan wrote:
> 
> Which version are you using?
> 

I'm using version 4.1. Also, except where noted in my original post, all
broker parameters are set to their default (i.e. all bar prefetch....all
queues are NON_PERSISTANT). Apart from the connections and queue mentioned,
there are another 12 connections to the broker 5 or 6 queues and a topic,
but these only send/receive messages irregularly and the workflows involved
are trivial. The machine on which the broker resides never uses more than 2
or 3% of CPU resources.

Many thanks for the response. Apologies for forgetting the most important
piece of information!


-- 
View this message in context: http://www.nabble.com/Blocking-consumers-not-consuming-immediately-tf4023758s2354.html#a11459288
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Blocking consumers not consuming immediately

Posted by James Strachan <ja...@gmail.com>.
Which version are you using?

On 7/4/07, TiredAndEmotional <st...@yahoo.co.uk> wrote:
>
> Hi,
>
> A brief outline of my set up: 5 dual core machines, one running activemq and
> a message producer communicating via a queue with 8 consumers spread across
> the other 4 machines. 2 classes of message, 2 of the consumers have
> selectors set so that they only select one class of message, the other 6
> accept either class of message. Consumption of messages of the selected
> class takes approximately 0.1 seconds, consumption of the other class takes
> approximately 7 seconds. Message consumption is single threaded on each
> consumer, and more or less completely chews up all of a single core's
> processing time.
>
> The loop to consume and process messages is as follows, i.e. the consumer
> blocks until it receives a message:
>
> while(keepLooping){
>                         try{
>                                 message=consumer.receive();
>                         }catch(JMSException e){
>                                 logger.warn("Problem with Node MessageConsumer.receive().", e);
>                                 sleep(1000);
>                                 continue;
>                         }
>                         //Check message isn't null
>                         if(message==null){//Can this ever occur?
>                                 sleep(1000);
>                                 continue;
>                         }
>                         //Unwrap message
>                         try{
>                                 m=(ServerMessage)(((ObjectMessage)message).getObject());
>                         }catch (Exception e){
>                                 logger.info("Failed to extract ServerMessage from "+m+". Message
> discarded.");
>                                 continue;
>                         }
>                         //Process message
>                         process(m);
>                 }//end while(keepLooping)
>
> My problem is that when I look at the status of the queue on jconsole, often
> there will be a few (i.e. 1 to 5) messages on the queue whilst many of the
> consumers aren't doing anything. Messages are small, on the order of 1-2kb
> at most. I changed the prefetch value to 1 for the generic consumers and 3
> for the selector consumers, but this does not seem to have fixed the
> behaviour. The broker has enqueued/dequeued approximately 340000 messages at
> this point in time. Consumers have been restarted a number of times,
> including very recently, and this has not affected the behaviour.
>
> To give an idea of the size of delays, sometimes messages are received by a
> consumer 2 minutes or more after they have been sent, when it is clear that
> the total amount of processing time required for all messages sent is much,
> much, much less than the consumer time available, i.e. there is no load
> explanation for the delay. In particular the queue never grew to more than 4
> or 5 pending messages in this 2 minute period, hence the greatest possible
> load delay would have been 10 seconds rather than 2 minutes.
>
> Does anyone have any ideas as to what might be causing this?
>
> Many thanks for your responses in advance.
>
> Best Regards,
>
> Steve Siller
> --
> View this message in context: http://www.nabble.com/Blocking-consumers-not-consuming-immediately-tf4023758s2354.html#a11428816
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/