title: How to publish to multiple queues with work queue behavior?
body: <p>Using RabbitMQ, I have two types of consumers: FileConsumer writes messages to file and MailConsumer mails messages. There may be multiple consumers of each type, say three running MailConsumers and one FileConsumer instance.</p>
  
  <p>How can I do this:</p>
  
  <ul>
  <li>Each published message should be handled by exactly one FileConsumer instance and one MailConsumer instance</li>
  <li>Publishing a message should be done once, not one time for each queue (if possible)</li>
  <li>If there are no consumers connected, messages should be queued until consumed, not dropped</li>
  </ul>
  
  <p>What type of exchange etc should I use to get this behavior? I'd really like to see some example/pseudo-code to make this clear.</p>
  
  <p><img src="https://i.stack.imgur.com/aszQd.png" alt="queues"></p>
  
  <p>This should be easy to do, but I couldn't figure it out from the docs. It seems the <a href="https://www.rabbitmq.com/tutorials/tutorial-three-java.html" rel="nofollow noreferrer">fanout example</a> should work, but I'm confused with these "anonymous queues" which seems like it will lead to sending same message into each consumer.</p>