activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Blocking consumers not consuming immediately
Date Fri, 06 Jul 2007 05:51:57 GMT
Which version are you using?

On 7/4/07, TiredAndEmotional <stevesiller@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/

Mime
View raw message