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: setting a MessageListener on a consumer?
Date Tue, 25 Mar 2008 09:31:28 GMT
On 24/03/2008, Andrew M <andrew@oc384.net> wrote:
> I'm using the method below to create a Topic and Consumer and register my
>  MessageListener.  I'm worried that with a retroactive consumer I'm missing
>  messages between the .createConsumer() method and when the MessageListener
>  is actually registered with the MessageConsumer.  Shouldn't there be some
>  way to set the listener before firing up the consumer?
>
>
>
>  public void subscribe(String destName, MessageListener l) throws
>  JMSException {
>
>         char c = destName.contains("?")?'&':'?';
>
>         destName = destName + c + "consumer.retroactive=true";
>
>         System.out.println("ActiveMqClient subscribe " + destName);
>
>         MessageConsumer mc = session.createConsumer(
>  session.createTopic(destName) );
>
>         mc.setMessageListener(l);
>
>     }

Thats the JMS spec for you :)

You can create the consumer, then start the connection when everything
is all setup to commence delivery.

Though the ActiveMQ implementation should buffer up messages inside
the consumer until either its setMessageListener() method is called,
or a receive*() method is invoked.

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

Open Source Integration
http://open.iona.com

Mime
View raw message