[rabbitmq-discuss] how to send a message including a array via .net client?
Chen Houwu
chenhouwu at gmail.com
Tue Jan 4 08:27:42 GMT 2011
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
More information about the rabbitmq-discuss
mailing list