[rabbitmq-discuss] Best practice for supporting both, XML and JSON messages

Tony Garnock-Jones tonygarnockjones+rabbitmq at gmail.com
Tue Nov 29 13:44:15 GMT 2011


On 28 November 2011 20:49, Julio Polo <julio at hawaii.edu> wrote:

> Would it be unusual for a producer to publish two versions of every
> message, one in XML, another in JSON?   If it's not unusual, is the
> typical implementation to set up a separate exchange for each format?
>

That would work fine. Another possibility is that if you can mechanically
compute the one from the other, you might

   - make your producers emit one (say, the JSON)
   - have a special consumer program listening to the exchange for
   JSON-formatted messages, which
      - translates each message into XML, and
      - posts the translation back into the exchange (or a different one;
      or with a different routing key)

So long as you make sure to tag messages with their MIME type in the
content-type header, the translator process won't get confused. The benefit
is that your producers are simpler, and the logic for understanding the
equivalences between the JSON and the XML is gathered all in one place.

Regards,
  Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111129/f4581454/attachment.htm>


More information about the rabbitmq-discuss mailing list