title: How is concurrency in Spring AMQP Listener Container implemented?
body: <p>My container XML config:</p>
  
  <pre><code>&lt;rabbit:listener-container
          connection-factory="myConnectionFactory"
          acknowledge="none"
          concurrency="10"
          requeue-rejected="false"&gt;
      &lt;rabbit:listener ref="myListener" queues="myQueue"/&gt;
  &lt;/rabbit:listener-container&gt;
  </code></pre>
  
  <p>and <code>myListener</code> is just a class</p>
  
  <pre><code>@Component("myListener")
  public class MyListener implements MessageListener {
      @Autowired
      SomeDependency dependency;
      ....
  }
  </code></pre>
  
  <p>I've specified <code>concurrency="10"</code> in my XML. What does this mean <strong>exactly</strong>?</p>
  
  <hr>
  
  <p>I've found <a href="http://docs.spring.io/spring-amqp/docs/1.2.1.RELEASE/api/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.html#setConcurrentConsumers%28int%29">some docs</a>. They are not that helpful stating:</p>
  
  <blockquote>
    <p>Specify the number of concurrent consumers to create. Default is 1.</p>
  </blockquote>
  
  <hr>
  
  <p>What I am interested in is whether <code>MyListener</code> has to be thread safe i.e.</p>
  
  <ul>
  <li>are there many instances created or single instance used by many threads?</li>
  <li>can I access instance fields w/o synchronization?</li>
  <li>is <code>SomeDependency dependency</code>  instantiated once or for each thread/instance?</li>
  <li>does <code>dependency</code> need to be thread safe?</li>
  </ul>