title: RabbitMQ by Example: Multiple Threads, Channels and Queues
body: <p>I just read <a href="http://www.rabbitmq.com/api-guide.html" rel="noreferrer">RabbitMQ's Java API docs</a>, and found it very informative and straight-forward. The example for how to set up a simple <code>Channel</code> for publishing/consuming is very easy to follow and understand. But it's a very simple/basic example, and it left me with an important question: <strong>How can I set up 1+ <code>Channels</code> to publish/consume to and from multiple queues?</strong></p>
  
  <p>Let's say I have a RabbitMQ server with 3 queues on it: <code>logging</code>, <code>security_events</code> and <code>customer_orders</code>. So we'd either need a single <code>Channel</code> to have the ability to publish/consume to all 3 queues, or more likely, have 3 separate <code>Channels</code>, each dedicated to a single queue.</p>
  
  <p>On top of this, RabbitMQ's best practices dictate that we set up 1 <code>Channel</code> per consumer thread. For this example, let's say <code>security_events</code> is fine with only 1 consumer thread, but <code>logging</code> and <code>customer_order</code> both need 5 threads to handle the volume. So, if I understand correctly, does that mean we need:</p>
  
  <ul>
  <li>1 <code>Channel</code> and 1 consumer thread for publishing/consuming to and from <code>security_events</code>; and</li>
  <li>5 <code>Channels</code> and 5 consumer threads for publishing/consuming to and from <code>logging</code>; and</li>
  <li>5 <code>Channels</code> and 5 consumer threads for publishing/consuming to and from <code>customer_orders</code>?</li>
  </ul>
  
  <p>If my understanding is misguided here, please begin by correcting me. Either way, could some battle-weary RabbitMQ veteran <strong>help me "connect the dots" with a decent code example for setting up publishers/consumers that meet my requirements here?</strong> Thanks in advance!</p>