[rabbitmq-discuss] Fwd: channel.basicPublish - sending json data

Ben Hood 0x6e6562 at gmail.com
Sat Jul 4 13:27:39 BST 2009


---------- Forwarded message ----------
From: Ben Hood <0x6e6562 at gmail.com>
Date: Sat, Jul 4, 2009 at 1:27 PM
Subject: Re: [rabbitmq-discuss] channel.basicPublish - sending json data
To: Aljosa Mohorovic <aljosa.mohorovic at gmail.com>


Aljosa,

On Fri, Jul 3, 2009 at 3:07 PM, Aljosa
Mohorovic<aljosa.mohorovic at gmail.com> wrote:
> i'm trying to use channel.basicPublish to send json encoded data but
> with no luck.
> there is com.rabbitmq.tools.json.JSONWriter but i have no idea how
> should it be used?
> could somebody point me to some related docs or post a simple example?
>
> i was trying to encode HashMap to json and then use something like:
> -----------------------------------------------------------------------------------------
> AMQP.BasicProperties prop = new AMQP.BasicProperties();
> prop.contentType = "application/json";
> prop.contentEncoding = "utf-8";
> channel.basicPublish("ex", "route", prop, msg);
> -----------------------------------------------------------------------------------------
>
> i did try to find something useful in rabbitmq archives but there is
> only one message that mentions JSONWriter.
> any tips/comments appreciated.

Have a look at the HelloJsonClient and HelloJsonServer examples in the
Java client. Basically there is a JSON serializer implementation in
the examples directory and all this does is pack and unpack JSON
objects.

HTH,

Ben




More information about the rabbitmq-discuss mailing list