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

Marek Majkowski majek04 at gmail.com
Wed Dec 29 10:47:44 GMT 2010


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.aspx
http://stackoverflow.com/questions/571168/what-json-library-works-well-for-you-in-net/571178#571178

Cheers,
  Marek

On Mon, Dec 27, 2010 at 11:22, Chen Houwu <chenhouwu 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-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>


More information about the rabbitmq-discuss mailing list