activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Wootton" <>
Subject Multiple Consumers
Date Thu, 25 May 2006 10:03:11 GMT
** Apologies if this came through yesterday.  I sent it once but don't
think it left my outbox! **

I'm new to messaging so forgive me if this is a silly question.

I would like a number of in-process consumers subscribing to different

Whenever one of these topics ticks, I would like to callback to a Java

What is the right idiom for doing this?  Something like the following is
fine in the scenario where we only have a single consumer:

while ( ( message = consumer.receive( 10000 )  ) != null )
     processMessage( message );

But clearly isn't what we need where we have multiple consumers.

I've considered placing each consumer in it's own thread, but I'd like
the callback to be called in a deterministic order (ie the same order
that the message arrives in.)  The semantics of the avaialble receive
methods also don't seem to fit with doing this.

                new Thread()
                    public void run()
                            Message message;
                            while ( ( message = consumer.receive(
                            1000000 )  ) != null )
                                processMessage( message );
                        catch( Exception exception )

Is there any example code around for this?

Thanks in advance
  Benjamin Wootton

View raw message