jsr343-experts@jms-spec.java.net

[jsr343-experts] Clarification on JMSContext::createConsumer

From: Clebert Suconic <clebert.suconic_at_gmail.com>
Date: Mon, 9 Dec 2013 09:10:48 -0500

The following code here would work on the reference implementation...


Message msg1 = context.createConsumer(queue1).receive(5000);
Message msg2 = context.createConsumer(queue1).receive(5000);



and I just tried on my implementation and it doesn't work of course... as I
create one consumer per call. Things like read-ahead would make it cache on
the client...


to make it always work, I would have to create a cache for createConsumer,
but however, there's a complication on setMessageListener:


JMSConsumer consumer1 = context.createConsumer(queue1);
consumer1.setMessageListener(listener1);
JMSConsumer consumer2 = context.createConsumer(queue1);
consumer2.setMessageListener(listener2);



If I make a cache, the second call would return the same consumer and hence
the setMessageListener on listener2 wouldn't work. I could of course
clear my cache on the implementation once setMessageListener is used....
However it's a bit weird since I won't have access to close the consumer
any longer.



this goes related to a previous discussion on receiving messages nonymously
such as:


context.createConsumer(queue1).receive(TIMEOUT);




Any thoughts?