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

DeckerEgo deckerego at gmail.com
Tue Nov 29 04:45:06 GMT 2011


The way the Spring AMQP project does it is by looking for a Content-
Type and Encoding header (not unlike HTTP) to determine how to marshal
the message. So if a Content-Type is JSON with UTF-8 Encoding it would
attempt to create a string using UTF-8 encoding and then unmarshal the
message using a JSON message decoder.

You could do something similar where you set Content-Type and Encoding
headers on your message, then encode/decode based on the type. It
would then be up to the endpoint creating the message to request its
desired format.

On Nov 28, 8:49 pm, Julio Polo <ju... 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?
> I thought about encoding both formats into a single message (using
> MIME for example) but that puts an extra burden that I don't my
> consumer audience to have.
>
> Julio Polo
> University of Hawaii
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list