activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prademak <>
Subject Setting message selector synchronously?
Date Tue, 31 Mar 2009 13:13:49 GMT

I'm setting the message selector for a non-persistent topic subscription at
runtime via the
ActiveMQActivationSpec.setMessageSelector and then restarting the
org.jencks.JCAConnector as follows: 

..."Setting selector to: " + selector);
Thread.sleep(WAIT_FOR_SELECTOR_SET_MS); // Wait for the selector to be
set/activated on the broker

(I'm using ActiveMQ 5.2.0 and Jencks 2.1)			

Apparently, the message selector is set asynchronously, since when in my
tests I directly start sending messages after the call to
setMessageSelector(..) and restarting the connector, I still receive
messages that should have been rejected based on the new selector. However,
if I wait for a few seconds, and then start sending the messages, everything
seems to be working fine. 

I ran into the same issue when I was using Spring's JmsTemplate +
(I've moved from JmsTemplate to Jencks to prevent me
from missing messages (
JmsTemplate gotchas ))  
When using Spring I set the message selector in the following way:

DefaultMessagListenerContainer dmlc;
String selector = JMSSelectorCreator.createJMSKeySelector(allKeys);
if (dmlc.getCacheLevel() > DefaultMessageListenerContainer.CACHE_CONSUMER) {
	logger.warn("Cache level of DefaultMessageListenerContainer is  >
CACHE_CONSUMER, therefore a restart of the container is required to
activate" +
					" a new Message Selector. Consider setting a lower cache level.");

However, as noted before, waiting for the message to be set/activated was
still required.

Which leads me to my question:
Is there any way of getting notified when the message selector has been
set/activated on the broker? 
(I've looked into Advisory messages, but these don't seems to provide
information on selectors) Or is there a method to set the selector that
blocks until the selector has actually been set/activated on the server?


View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message