I currently have a JMSListener as shown below. It uses a selector of a value in a properties file. This works fine.
@JmsListener(destination = "myQueueDest",
selector = MyHeaders.SELECTOR_KEY + " = '${myapp.selector_val}'")
private void consumeData(MyCustomObj mycustomObj) { }
I have a need now to use a dynamic selector with a value in memory, rather than the spring property. Is there a way to use JMSListener (or some other listener mechnaism) to do a selection off the ActiveMQ queue?
Update:
It may be possible to assign an ID to my @JMSListener
, and then retrieve it from my JmsListenerEndpointRegistry
bean. Get the listener container by ID, cast it to DefaultMessageListenerContainer
, and call setMessageSelector()
, although I'm not entirely sure if this will work yet.
This requires setting my DefaultJmsListenerContainerFactory bean to have the cache level of CACHE_SESSION
.
But this doesn't seem to work, as the listener picks up all messages, regardless of what I set the message selector to be.