Re: how to use JmsQueueConnectionConsumer?

William Moore <[email protected]>
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
On 9 Feb, 2005, at 2:25 pm, Herbert.Helmstreit-lruo3ZhV/[email protected] wrote:

> I've tried multible listeners on a single queue but not with OpenJMS 
> and
> not with good results.

I have used multiple listeners on a single queue. I have not used it 
for a while, but I do not recall any problems when I was using it. Each 
listener is an instance of the same class which implements 
MessageListener and ExceptionListener. Here is an extract from what 
they do:

/* These are called after the object is created. I do not do them in 
the constructor, but they might work there as well */
  Properties props = new Properties();
  props.put(Context.INITIAL_CONTEXT_FACTORY, 
org.exolab.jms.jndi.InitialContextFactory.class.getName());
  props.put(Context.PROVIDER_URL, "rmi://localhost:1099/JndiServer");
  InitialContext context = new InitialContext(props);
  QueueConnectionFactory queueConnectionFactory = 
(QueueConnectionFactory)context.lookup("JmsQueueConnectionFactory");
  QueueConnection queueConnection = 
queueConnectionFactory.createQueueConnection();
  queueConnection.start();
  QueueSession queueSession = 
queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
  Queue queue = (Queue)context.lookup(queueName);
  QueueReceiver queueReceiver = queueSession.createReceiver(queue);
  queueReceiver.setMessageListener(this);
  queueConnection.setExceptionListener(this);

/* This processes the messages */
  public void onMessage(Message message) {
  }


William



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.