title: Spring 4.1 @JmsListener configuration
body: <p>I would like to use the new annotations and features provided in Spring 4.1 for an application that needs a JMS listener.</p>
  
  <p>I've carefully read the notes in the <a href="https://spring.io/blog/2014/04/30/spring-4-1-s-upcoming-jms-improvements" rel="noreferrer">Spring 4.1 JMS improvements post</a> but I continue to miss the relationship between <code>@JmsListener</code> and maybe the <code>DestinationResolver</code> and how I would setup the application to indicate the proper <code>Destination</code> or <code>Endpoint</code>.</p>
  
  <p>Here is the suggested use of @JmsListener</p>
  
  <pre><code>@Component
  public class MyService {
  
      @JmsListener(containerFactory = "myContainerFactory", destination = "myQueue")
      public void processOrder(String data) { ... }
  }
  </code></pre>
  
  <p>Now, I can't use this in my actual code because the "myQueue" needs to be read from a configuration file using <code>Environment.getProperty()</code>.</p>
  
  <p>I can setup an appropriate myContainerFactory with a <code>DestinationResolver</code> but mostly, it seems you would just use <code>DynamicDestinationResolver</code> if you don't need JNDI to lookup a queue in an app server and didn't need to do some custom reply logic.  I'm simply trying to understand how Spring wants me to indicate the name of the queue in a parameterized fashion using the <code>@JmsListener</code> annotation.</p>
  
  <p>Further down the blog post, I find a reference to this Configurer: </p>
  
  <pre><code>@Configuration
  @EnableJms
  public class AppConfig implements JmsListenerConfigurer {
  
  @Override
  public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
      registrar.setDefaultContainerFactory(defaultContainerFactory());
  
      SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
      endpoint.setDestination("anotherQueue");
      endpoint.setMessageListener(message -&gt; {
          // processing
      });
      registrar.registerEndpoint(endpoint);
  }
  </code></pre>
  
  <p>Now, this makes some amount of sense and I could see where this would allow me to set a Destination at runtime from some external string, but this seems to be in conflict with using <code>@JmsListener</code> as it appears to be overriding the annotation in favor of <code>endpoint.setMessageListener</code> in the code above.</p>
  
  <p>Any tips on how to specify the appropriate queue name using <code>@JmsListener</code>?</p>