title: how to set basicQos in spring amqp for fair dispatch?
body: <p>This is my current spring amqp configuration</p>
  
  <pre><code>&lt;rabbit:connection-factory id="rabbitConnectionFactory"
      port="${rabbitmq.port}" host="${rabbitmq.host}" username="${rabbitmq.username}" password="${rabbitmq.password}"/&gt;
  
  &lt;rabbit:admin id="rabbitmqAdmin" connection-factory="rabbitConnectionFactory" /&gt;
  
  &lt;rabbit:template id="importAmqpTemplate"
      connection-factory="rabbitConnectionFactory"&gt;
  &lt;/rabbit:template&gt;
  </code></pre>
  
  <p>and this is my exchanges, queues, listeners, replyQueues, replyHandlers configuration</p>
  
  <pre><code>&lt;rabbit:queue name="${process1.queue}" /&gt;
  &lt;rabbit:queue name="${process1.reply.queue}" /&gt;
  
  &lt;rabbit:queue name="${process2.queue}" /&gt;
  &lt;rabbit:queue name="${process2.reply.queue}" /&gt;
  
  &lt;rabbit:direct-exchange name="${myExchange}"&gt;
      &lt;rabbit:bindings&gt;
          &lt;rabbit:binding queue="${process1.queue}"
              key="${process1.routing.key}" /&gt;
          &lt;rabbit:binding queue="${process2.queue}"
              key="${process2.routing.key}" /&gt;
      &lt;/rabbit:bindings&gt;
  &lt;/rabbit:direct-exchange&gt;
  
  &lt;rabbit:listener-container
      connection-factory="rabbitConnectionFactory" concurrency="${my.listener.concurrency}"
      requeue-rejected="false"&gt;
      &lt;rabbit:listener queues="${process1.queue}"
          ref="foundation" method="process1" /&gt;
      &lt;rabbit:listener queues="${process2.queue}"
          ref="foundation" method="process2s" /&gt;
  &lt;/rabbit:listener-container&gt;
  
  
  &lt;beans:beans profile="master"&gt;
  
      &lt;beans:bean id="process1Lbq" class="java.util.concurrent.LinkedBlockingQueue" /&gt;
      &lt;beans:bean id="process2Lbq" class="java.util.concurrent.LinkedBlockingQueue" /&gt;
  
      &lt;beans:bean id="process1sReplyHandler"
          class="com.stockopedia.batch.foundation.ReplyHandler"
          p:blockingQueue-ref="process1Lbq" /&gt;
  
      &lt;beans:bean id="process2ReplyHandler"
          class="com.stockopedia.batch.foundation.ReplyHandler"
          p:blockingQueue-ref="process2Lbq" /&gt;
  
      &lt;rabbit:listener-container
          connection-factory="rabbitConnectionFactory" concurrency="1"
          requeue-rejected="false"&gt;
          &lt;rabbit:listener queues="${process1.reply.queue}"
              ref="process1sHandler" method="onMessage" /&gt;
          &lt;rabbit:listener queues="${process2.reply.queue}"
              ref="process2ReplyHandler" method="onMessage" /&gt;
      &lt;/rabbit:listener-container&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>I have set this up on 6 different servers, and queuing up messages from master servers only. Other servers are only processing messages. All servers has same number of listeners running as set by concurrency.</p>
  
  <p>The problem is, messages takes different time to process. Some messages take long time. So currently some of the servers do not pick up messages from queues even all listeners on those servers are done with processing there messages. </p>
  
  <p>I can see the pending messages in queue to be processed and some servers just sitting idle. I want those server to pick up remaining messages while other servers are busy in processing their messages. </p>
  
  <p>Do I need to set basic_Quos as mentioned in tutorial <a href="http://www.rabbitmq.com/tutorials/tutorial-two-java.html" rel="nofollow">http://www.rabbitmq.com/tutorials/tutorial-two-java.html</a> (Fair Dispatch) ?</p>
  
  <pre><code>int prefetchCount = 1;
  channel.basicQos(prefetchCount);
  </code></pre>
  
  <p>or is it default for spring ampq ? If not how do i do it ?</p>