title: Bidirectional Messaging Queue
body: <p>This seems like a question belonging to a FAQ, but I cannot phrase the question to find it answered.<br>
  Anyway, I am currently investigating message queues (glossed over ZeroMQ, RabbitMQ tutorials) and I think MQs fit nicely into transformational dataflow - listen on Q1 for messages in format F1, transform into F2 and put transformed message on Q2. Natural question arises of what happens if transformation is inherently bidirectional and there is no well defined consumer and producer, e.g. yaml&lt;->json converter?</p>
  
  <p>As far as I understand message queues are inherently unidirectional and for bidirectional messaging I see two "solutions":</p>
  
  <ul>
  <li>Have two distinct input output queues, which translates into 4 in this example: json.in, json.out, yaml.in, yaml.out;</li>
  <li>Connect converter to both ends of JSON queue, to distinguish between raw json and converted from yaml, wrap messages in messages specifying whether this is incoming or outgoing message. But as a consequence, converter now gets a ton of messages that it has to parse and reinsert back to queue - sounds hellishly inefficient.</li>
  </ul>
  
  <p>Former solution sounds like a way to go, unless latter is delegated to MQ broker in some form (e.g. consumer/producer IDs: <code>json.out, id = connect_produce("json", null); json.in = connect_consume("json", id);</code>) and broker just figures out not to send message to consumer if the message was produced by the same entity. As fas as I understand any kind of filtering will boil down to message tagging (topic exchange in RabbitMQ), which requires multiple queues.</p>
  
  <p>So my question is how is this done in practice? Sticking to multiple queues or some frameworks implement bidirectional queues? Or maybe I'm missing something obvious here?</p>