title: JMSListener - dynamic selector
body: <p>I currently have a JMSListener as shown below. It uses a selector of a value in a properties file. This works fine.</p>
  
  <pre><code> @JmsListener(destination = "myQueueDest",
       selector = MyHeaders.SELECTOR_KEY + " = '${myapp.selector_val}'")
   private void consumeData(MyCustomObj mycustomObj) { }
  </code></pre>
  
  <p>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? </p>
  
  <p>Update:</p>
  
  <p>It may be possible to assign an ID to my <code>@JMSListener</code>, and then retrieve it from my <code>JmsListenerEndpointRegistry</code> bean. Get the listener container by ID, cast it to <code>DefaultMessageListenerContainer</code>, and call <code>setMessageSelector()</code>, although I'm not entirely sure if this will work yet.</p>
  
  <p>This requires setting my DefaultJmsListenerContainerFactory bean to have the cache level of <code>CACHE_SESSION</code>.</p>
  
  <p>But this doesn't seem to work, as the listener picks up all messages, regardless of what I set the message selector to be.</p>