activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prademaker <>
Subject Setting message selector synchronously
Date Tue, 31 Mar 2009 14:16:22 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 after the call to setMessageSelector(..) and restarting the connector
I directly start sending messages to the topic, I still receive messages
that should have been rejected based on the new selector. 
However, if I wait for a few seconds, and then send the messages, the
selector does seem to be set/activated and the correct messages are

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 seem to provide
information about 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