title: Spring AMQP single consumer parallelism with prefetch
body: <p>We have a project that's using Spring-AMQP to consume messages from our RabbitMQ broker. We would like to increase the concurrency on the consuming side so that multiple worker threads can process messages in parallel. I began by reading the documentation for the native RabbitMQ client, and that lead me to a design of using a single consumer, and a prefetch count > 1 to control for parallelism. Using the RabbitMQ client directly, this seems quite natural. The <code>handleDelivery</code> method of the <code>DefaultConsumer</code> can spawn a new <code>Runnable</code> that does the work and acknowledges the message at the end of the work. The prefetch count effectively controls the maximum number of <code>Runnable</code>s that the consumer spawns.</p>
  
  <p>However, this design does not seem translatable to the Spring-AMQP world. In the <code>SimpleMessageListenerContainer</code>, for each AMQP consumer, all messages get delivered into a single <code>BlockingQueueConsumer</code>, and a single thread delivers messages from the <code>BlockingQueueConsumer</code>'s blocking queue to the <code>MessageListener</code>. Even though the <code>SimpleMessageListenerContainer</code> supports a <code>TaskExecutor</code>, the <code>TaskExecutor</code> is only used to run one task per consumer. So to process multiple messages in parallel one has to use multiple consumers.</p>
  
  <p>This leads me to a few questions about parallelism with Spring-AMQP. First, is my initial design with single consumer and high prefetch count a valid way to achieve parallelism with AMQP? If so, why does Spring-AMQP eschew this design in favor of a thread-per-consumer design? And is it possible to customize Spring-AMQP to make single-consumer parallelism possible?</p>