This seems like a question belonging to a FAQ, but I cannot phrase the question to find it answered.
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<->json converter?
As far as I understand message queues are inherently unidirectional and for bidirectional messaging I see two "solutions":
- Have two distinct input output queues, which translates into 4 in this example: json.in, json.out, yaml.in, yaml.out;
- 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.
Former solution sounds like a way to go, unless latter is delegated to MQ broker in some form (e.g. consumer/producer IDs: json.out, id = connect_produce("json", null); json.in = connect_consume("json", id);
) 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.
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?