[rabbitmq-discuss] how to send a message including a array via .net client?

Steven Taylor taylste at gmail.com
Tue Jan 4 10:22:47 GMT 2011


Hi Chen,

I like binary serialization at the moment.

http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatter.aspx

In future I'd like to use binary Json, and there's also google protobuffers
which look pretty good (not sure on how good the .net support is though).
Json is certainly better IMHO than XML. The binary / cross-platform binary
options are more suited to my purposes.

Under .net Json / Binary / Soap serialization works just about the same way.

http://pietschsoft.com/post/2008/02/NET-35-JSON-Serialization-using-the-DataContractJsonSerializer.aspx

Start off serializing / deserializing an object with one property. Get that
going and you'll find it's the same set of steps for anything that inherits
from "object" (includes arrays).  Tag it up / decorate it correctly, and job
done.  Step two, see if Rabbit handles it faithfully (it does for me).

cheers,
-Steven
On 4 January 2011 08:27, Chen Houwu <chenhouwu at gmail.com> wrote:

> Do you mean that .net client has no build-in support for simple data
> structure?
> But I have found it should support according to the AMQP 1.0
> specification.
> AMQP is a binary protocol, but json is text.
> Though I can send binary content after encoding it to BASE64, it is
> too inefficient.
>
> It seams as if the python client support array and dictionary
> object.....
>
> On 2010年12月29日, 下午6时47分, Marek Majkowski <maje... at gmail.com> wrote:
> > Hi,
> >
> > I think you should be using some standardized encoding,
> > like for example json.
> >
> > Take a look at this library:
> http://james.newtonking.com/pages/json-net.aspxhttp://stackoverflow.com/questions/571168/what-json-library-works-wel.
> ..
> >
> > Cheers,
> >   Marek
>  >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Dec 27, 2010 at 11:22, Chen Houwu <chenho... at gmail.com> wrote:
> > >   I am a newbie to rabbitmq, I want to send a message object as
> > > following via .net client:
> >
> > >   public class Message
> > >    {
> > >        public int ID { get; set; }
> > >        public string Name { get; set; }
> > >        public byte[] Binary { get; set; }
> > >        public string[] Infos{get;set;}
> > >        public Dictionary<string,int> CountMap { get; set; }
> > >    }
> >
> > > Here is my code:
> > > -------------------------------------------
> > > var builder = new
> > > RabbitMQ.Client.Content.StreamMessageBuilder(_channel);
> > > builder.writeObject(msg.ID);
> > > builder.writeObject(msg.Name);
> > > /*----------How to deal with msg.Infos and CountMap here?------------/
> >
> > > /*shoud it be written by myself such as: */
> > > builder.writeObject(infos.count)
> > > foreach(var info in infos)
> > > {
> > >   builder.writerObject(info)
> > > }
> > > /* or the suporting to array and dictionary already exists?*/
> >
> > > /* I have found in"src/client/impl/WireFormatting.cs", there are
> > > methods like "WriteArray", and "WriteTable"*/
> >
> > >  IBasicProperties props = _channel.CreateBasicProperties();
> > > props.DeliveryMode = 2;
> > >  _channel.BasicPublish(_exchangeName, "some key", props,
> > > builder.GetContentBody());
> > > -----------------
> >
> > > _______________________________________________
> > > rabbitmq-discuss mailing list
> > > rabbitmq-disc... at lists.rabbitmq.com
> > >https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> >
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-disc... at lists.rabbitmq.comhttps://
> lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>  _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110104/8245a5f2/attachment.htm>


More information about the rabbitmq-discuss mailing list