title: Spring Boot RabbitMQ Single Queue with multiple consumers
body: <p>I am new in Rabbitmq and I want to use single queue with multiple consumers, please help me for multiple consumers and how can we handle request for multiple consumers from single queue ?</p>
  <p>Below is my code for Single Queue and Single Consumers</p>
  <p><strong>My Configuration Class</strong></p>
  <pre><code>@Configuration
  public class ConfigureRabbitMq {
  
      public static final String EXCHANGE_NAME = &quot;mikeexchange2&quot;;
      public static final String QUEUE_NAME = &quot;mikequeue2&quot;;
  
  
      @Bean
      Queue createQueue() {
          return new Queue(QUEUE_NAME, true, false, false);
      }
  
      @Bean
      TopicExchange exchange(){
          return new TopicExchange(EXCHANGE_NAME);
      }
  
      @Bean
      Binding binding(Queue q, TopicExchange exchange){
          return BindingBuilder.bind(q).to(exchange).with(&quot;mike.#&quot;);
      }
  
      @Bean
      SimpleMessageListenerContainer container(ConnectionFactory connectionFactory
              , MessageListenerAdapter messageListenerAdapter){
          SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
          container.setConnectionFactory(connectionFactory);
          container.setQueueNames(QUEUE_NAME);
          container.setMessageListener(messageListenerAdapter);
          return container;
      }
  
  
      @Bean
      MessageListenerAdapter listenerAdapter(Receive handler){
          return new MessageListenerAdapter(handler, &quot;handleMessage&quot;);
      }
  }
  </code></pre>
  <p><strong>My Receiver Class</strong></p>
  <pre><code>@Service
  public class Receive {
  
      public void handleMessage(String messageBody){
          System.out.println(&quot;HandleMessage!!!&quot;);
          System.out.println(messageBody);
          
      }
  </code></pre>
  <p>}</p>
  <p><strong>My Sender Class</strong></p>
  <pre><code>@RestController
  public class Send {
  
      private final  RabbitTemplate rabbitTemplate;
      
      public  Send(RabbitTemplate rabbitTemplate) {
          this.rabbitTemplate = rabbitTemplate;
      }
      
      
      
      @RequestMapping(method = RequestMethod.GET, value = &quot;/api/send/{msg}&quot;)
      public String sendMessage(@PathVariable(&quot;msg&quot;) String themessage){
          
          for(int i=0;i&lt;5000000;i++) {
              rabbitTemplate.convertAndSend(ConfigureRabbitMq.EXCHANGE_NAME,
                      &quot;mike.springmessages&quot;, themessage+&quot;&quot;+Integer.toString(i));
          }
          return &quot;We have sent a message! :&quot; + themessage;
      }
  }
  </code></pre>