Bill Moseley | 3 Jan 03:18 2011

prefetch_count with Net::RabbitMQ?

I hope I didn't miss something, but following the tutorial (http://www.rabbitmq.com/tutorial-two-python.html) with the Perl client I didn't see how to set the prefetch_count to 1.  Is that possible?


If I have a number of consumers I don't want a consumer that gets stuck on a long running task to prevent jobs from flowing to other workers.

<div>
<p>I hope I didn't miss something, but following the tutorial (<a href="http://www.rabbitmq.com/tutorial-two-python.html">http://www.rabbitmq.com/tutorial-two-python.html</a>) with the Perl client I didn't see how to set the prefetch_count to 1. &nbsp;Is that possible?</p>
<div>

<br>
</div>
<div>If I have a number of consumers I don't want a consumer that gets stuck on a long running task to prevent jobs from flowing to other workers.</div>
<div><br></div>
<div>Thanks,<br clear="all"><br>-- <br>
Bill Moseley<br><a href="mailto:moseley@..." target="_blank">moseley@...</a><br>
</div>
</div>
Emile Joubert | 3 Jan 16:00 2011

Re: prefetch_count with Net::RabbitMQ?


Hi Bill,

Op 03/01/2011 02:18, het Bill Moseley geskryf:
> I hope I didn't miss something, but following the tutorial
> (http://www.rabbitmq.com/tutorial-two-python.html) with the Perl client
> I didn't see how to set the prefetch_count to 1.  Is that possible?
>
> If I have a number of consumers I don't want a consumer that gets stuck
> on a long running task to prevent jobs from flowing to other workers.

Net::RabbitMQ is a wrapper around the rabbitmq C client which lacks an 
API for setting QOS at this time. You could try one of the other Perl 
clients that offer QOS support.

If you have translated any of the tutorials to another language then you 
may want to consider contributing.

Regards

Emile
Vadim Chekan | 3 Jan 18:37 2011
Picon

Wcf one-way call

Hi all,

For cache invalidation purposes I am trying to implement a broadcast
as a one-way call using wcf. As long as it is a broadcast call, I
don't expect any response. So it must be one-way call. But I
experience blocking waiting for response until timeout. Most likely it
is because reasons mentioned in this article "One-way is not always
really one-way":
http://bloggingabout.net/blogs/gerben/archive/2010/02/01/wcf-best-practice-5-one-way-is-not-always-really-one-way.aspx

The Rabbit's Wcf documentation mentions that behavior *can* be marked
as one-way, in addition to a call, but it seems to me that it is
actually the only way to make one-way call working. Is there any way
to make an OperationContract one-way? Because if I mark the whole
service with one-way behavior, then I'll be in troubles if I'll mix
one and two way calls in the same service.

Vadim.

Some snippets of my code:
============================================
    [ServiceContract]
    public interface ICategoryService
    {
        [OperationContract(IsOneWay=true)]
        void InvalidateAll();
    }

        class Broadcast : ClientBase<ICategoryService>, ICategoryService
        {
            public Broadcast() : base("Category") { }

            public void InvalidateAll()
            {
                base.Channel.InvalidateAll();
            }
        }
...
...
            // broadcast the change
            using (var broadcast = new Broadcast())
            {
                broadcast.InvalidateAll();
                broadcast.Close();
            }
...
...
============================================

--

-- 
From RFC 2631: In ASN.1, EXPLICIT tagging is implicit unless IMPLICIT
is explicitly specified
drenz | 3 Jan 23:56 2011
Picon

Re: Rabbitmq Java Client Memory Leak?

Thanks for the help guys! I've resolved the issue.

Not surprisingly, this was my own fault. I had a long running database
connection in another layer of the code that was eating up memory.
Nothing was wrong with rabbitmq.

Thanks,

Dave

On Dec 12 2010, 3:02 pm, Benjamin Bennett <benbenn...@...>
wrote:
> Don't know if it is possible, I would attach the source to your
> debugger.That might give you some idea what is going on.
> I had  quick look at the QueueingConsumer code and it looks pretty
> strait forward.
>  What profiler are you using ? I am yourkit memory inspections would
> give you some idea what class is holding the reference.
>  Something is holding onto the bytes and it cannot be gc'd.
> Other item is the new ByteStreamInputArray() wonder if you can set
> that as a variable and set it to null after you read. But looking at
> the javadocs that shouldn't be the issue.
> I would still try it to 100% that isn't the issue.
>
>
>
>
>
>
>
>
>
> On Sun, Dec 12, 2010 at 1:36 PM, drenz <david.r...@...> wrote:
> > I've updated the code to explicitly set body = null after I am done
> > using it. See below.
>
> > However, the memory continues to build up. This is the only part of
> > the code that runs, so it has to be something in here.  It almost
> > looks like the QueueingConsumer object might be keeping these
> > references around.  Is that possible?
>
> > Thanks
>
> > byte[] body = delivery.getBody();
>
> > ObjectInputStream in = new ObjectInputStream(new
> > ByteArrayInputStream(body));
> > Status s = (Status) in.readObject();
>
> > body = null;
>
> > in.close();
>
> > in = null;
>
> > On Dec 12, 12:51 pm, Benjamin Bennett <benbenn...@...> wrote:
> >> Having a quick look at it make sure the line is not holding a
> >> reference , considering you are saying the profiler is saying that a
> >> reference is out there.
> >>  byte[] body = delivery.getBody();
> >> de references the delivery.getBody();
>
> >> if the body variable is referencing the delivery.getBody() it will
> >> prevent it from being gc'ed .
>
> >> On Sun, Dec 12, 2010 at 9:58 AM, drenz <david.r...@...> wrote:
> >> > Hello,
>
> >> > I have a pretty simple set up where I use the RabbitMQ client library
> >> > to pull objects from a RabbitMQ server.
>
> >> > Unfortunately, there seems to be some memory leak in my program
> >> > because it quickly consumes all of the heap memory with byte arrays.
> >> > I've increased the max memory for the JVM to 2 GB and it consumes all
> >> > of that too.
>
> >> > Here is the code I use to pull data from the queue.  Having used a few
> >> > Java profilers, it looks like the leak is associated with they
> >> > QueueingConsumer.Delivery object, because each Delivery object has a
> >> > member byte[] called _body.
>
> >> > Does anyone have any idea how I can ensure these arrays are garbage
> >> > collected / destroyed?
>
> >> > Thanks in advance!!!
>
> >> > Property values:
> >> > queue.user=guest
> >> > queue.password=guest
> >> > queue.virtualHost=/
> >> > queue.host=127.0.0.1
> >> > queue.hostPort=5672
> >> > queue.heartBeat=0
> >> > queue.exchange=myExchange
> >> > queue.queueName=dtt
> >> > queue.routingKey=dttRoute
>
> >> > Code:
>
> >> >        public void consume() throws IOException, ClassNotFoundException {
>
> >> >                ConnectionFactory factory = new ConnectionFactory();
> >> >                factory.setUsername(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.user"));
> >> >                factory.setPassword(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.password"));
> >> >                factory.setVirtualHost(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.virtualHost"));
> >> >                factory.setRequestedHeartbeat(Integer.parseInt(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.heartBeat")));
> >> >                factory.setHost(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.host"));
> >> >                factory.setPort(Integer.parseInt(PropertyUtil
> >> >                                .getProperyFile().getProperty("queue.hostPort")));
>
> >> >                boolean durable = true;
> >> >                boolean noAck = false;
>
> >> >                Connection conn = factory.newConnection();
>
> >> >                Channel channel = conn.createChannel();
>
> >> >                channel.basicQos(2);
> >> >                channel.exchangeDeclare(getExchangeName(), "direct", durable);
> >> >                channel.queueDeclare(getQueueName(), durable, false, false, null);
> >> >                channel.queueBind(getQueueName(), getExchangeName(),
> >> > getRoutingKey());
>
> >> >                QueueingConsumer consumer = new QueueingConsumer(channel);
> >> >                channel.basicConsume(getQueueName(), noAck, consumer);
>
> >> >                boolean runInfinite = true;
>
> >> >                java.sql.Connection sqlConn = null;
> >> >                sqlConn = DatabaseUtil.getConnection();
>
> >> >                long start = 0;
> >> >                long end = 0;
>
> >> >                while (runInfinite) {
> >> >                        start = System.currentTimeMillis();
> >> >                        QueueingConsumer.Delivery delivery = null;
> >> >                        try {
> >> >                                delivery = consumer.nextDelivery();
>
> >> >                        } catch (Exception ie) {
> >> >                                log.error(ie.getMessage(), ie);
> >> >                                continue;
> >> >                        }
>
> >> >                        byte[] body = delivery.getBody();
>
> >> >                        ObjectInputStream in = new ObjectInputStream(
> >> >                                        new ByteArrayInputStream(body));
>
> >> >                        Status s = (Status) in.readObject();
> >> >                        in.close();
> >> >                        in = null;
>
> >> >                        try {
>
> >> >                                try {
> >> >                                        process(s, sqlConn);
>
> >> >                                } catch (Exception e) {
> >> >                                        try{
> >> >                                                sqlConn = DatabaseUtil.getConnection();
> >> >                                        } catch (Exception e1){
> >> >                                                log.error(e.getMessage(), e1);
> >> >                                                throw e1;
> >> >                                        }
> >> >                                }
>
> >> >                                // only send an acknowledgement when the processing completed
> >> >                                // successfully
> >> >                                channel
> >> >                                                .basicAck(delivery.getEnvelope().getDeliveryTag(),
> >> >                                                                false);
>
> >> >                        } catch (Exception e) {
> >> >                                log.error(e.getMessage(), e);
> >> >                        }
>
> >> >                        end = System.currentTimeMillis();
> >> >                        delivery = null;
>
> >> >                        log.debug("Processing time: "+ (end - start) +" ms");
>
> >> >                }
> >> >                try {
> >> >                        sqlConn.close();
> >> >                } catch (SQLException e) {
> >> >                        // TODO Auto-generated catch block
> >> >                        log.error(e.getMessage(), e);
> >> >                }
>
> >> >                channel.close();
> >> >                conn.close();
>
> >> >        }
>
> >> > _______________________________________________
> >> > rabbitmq-discuss mailing list
> >> > rabbitmq-disc...@...
> >> >https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
> >> _______________________________________________
> >> rabbitmq-discuss mailing list
> >> rabbitmq-disc...@...://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-disc...@...
> >https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc...@...://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Bill Moseley | 4 Jan 00:13 2011

Web use scenarios

Hi,


I'm just starting out with RabbitMQ and trying to wrap my head around a few concepts.  I apologize if I ask something that should be obvious or I missed in the docs and faq.  I'm hoping someone can help with a few scenarios, and please point me to further reading as needed.

I'm curious about use-cases that are not directly related to RabbitMQ, but how to best use RabbitMQ in an web application's architecture.  Thes are probably very common situations.

1) Notification of job status and completion:  If the web app produces a request to generate an expensive PDF is there a common approach to detecting when the consumer is completed and the pdf is ready for downloading?  Should I create a single-use return queue with x-expires and/or x-message-ttl on the queue?   In a web app the web user may never come back to pick up the PDF.

2) Job sequencing:  What's a common approach to multiple step processing that must be done serially?  I.e. queue job "A" and when it's complete queue job "B".  Doesn't really seem like consumer "A" should be responsible for submitting job "B".  Is it better to create a consumer "AB" that submits "A" and waits for a message that "A" is complete and then submits job "B"?

3) Scheduling: I assume there's no facility for scheduling jobs to be delivered to consumers at some future time.  Is there a better approach than using cron to check the database for jobs that should be queued based on time?

4) Cancel a request:  We have some situations when a subsequent request should cancel processing of an earlier request.  (Frankly, I think this is a design problem on our end.)

5) Prevent duplicate job requests: In a web environment when things break problems often compound by users reloading requests that caused the problem in the first place.  I'm not sure RabbitMQ would be involved at all in this scenario, but I'm asking just in case. ;)  

Finally, it's great that RabbitMQ will send a message again if is is not ACK'd and a consumer closes its connection.  But, is there any kind of max retry count available?  That is, what's a good approach to prevent an errant job from killing all consumers one-by-one?

Thanks,

<div>
<p>Hi,</p>
<div><br></div>
<div>I'm just starting out with RabbitMQ and trying to wrap my head around a few concepts. &nbsp;I apologize if I ask something that should be obvious or I missed in the docs and faq. &nbsp;I'm hoping someone can help with a few scenarios, and please point me to further reading as needed.</div>

<div><br></div>
<div>

I'm curious about use-cases that are not directly related to RabbitMQ, but how to best use RabbitMQ in an web application's&nbsp;architecture. &nbsp;Thes are probably very common situations.</div>
<div><br></div>
<div>1) Notification of job status and completion: &nbsp;If the web app produces a request to generate an expensive PDF is there a common approach to detecting when the consumer is completed and the pdf is ready for downloading? &nbsp;Should I create a single-use return queue with x-expires and/or x-message-ttl on the queue? &nbsp; In a web app the web user may never come back to pick up the PDF.</div>

<div><br></div>
<div>2) Job sequencing: &nbsp;What's a common approach to multiple step processing that must be done serially? &nbsp;I.e. queue job "A" and when it's complete queue job "B". &nbsp;Doesn't really seem like consumer "A" should be responsible for submitting job "B". &nbsp;Is it better to create a consumer "AB" that submits "A" and waits for a message that "A" is complete and then submits job "B"?</div>

<div><br></div>
<div>3) Scheduling: I assume there's no facility for scheduling jobs to be delivered to consumers at some future time. &nbsp;Is there a better approach than using cron to check the database for jobs that should be queued based on time?</div>

<div><br></div>
<div>4) Cancel a request: &nbsp;We have some situations when a subsequent request should cancel processing of an earlier request. &nbsp;(Frankly, I think this is a design problem on our end.)</div>
<div><br></div>
<div>

5) Prevent duplicate job requests: In a web environment when things break problems often compound by users reloading requests that caused the problem in the first place. &nbsp;I'm not sure RabbitMQ would be involved at all in this scenario, but I'm asking just in case. ;) &nbsp;</div>

<div><br></div>
<div>Finally, it's great that RabbitMQ will send a message again if is is not ACK'd and a consumer closes its connection. &nbsp;But, is there any kind of max retry count available? &nbsp;That is, what's a good approach to prevent an errant job from killing all consumers one-by-one?</div>

<div><br></div>
<div>Thanks,</div>
<div><br></div>
<div>-- <br>Bill Moseley<br><a href="mailto:moseley@..." target="_blank">moseley@...</a><br>
</div>
</div>
Chen Houwu | 4 Jan 09:27 2011
Picon

Re: how to send a message including a array via .net client?

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
Emile Joubert | 4 Jan 11:21 2011

Re: how to send a message including a array via .net client?

Hi Chen,

If your message producers and consumers are both .net then you may use 
any of the built-in .net serialisers.
See http://msdn.microsoft.com/en-us/library/7ay27kt9.aspx

If you are in a mixed language environment then a format like YAML, 
JSON, protocol buffers or perhaps XML makes more sense.

On 04/01/11 08:27, Chen Houwu 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.

The .net client supports byte arrays for message payloads as required by 
the AMQP 0.9.1 spec.

> AMQP is a binary protocol, but json is text.
> Though I can send binary content after encoding it to BASE64, it is
> too inefficient.

There is no need to use base64. Base64 would only be required if the 
payload needed to be 7bit clean.

Regards

Emile
Steven Taylor | 4 Jan 11:22 2011
Picon

Re: how to send a message including a array via .net client?

Hi Chen,
 
I like binary serialization at the moment.
 
 
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.
 

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-ETbvJ2rUIr4qBm01orBoR9BPR1lH4CV8@public.gmane.org
> >https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc...-ETbvJ2rUIr7Rv0WFA/ZhaQ@public.gmane.orgbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

<div>
<div>Hi Chen,</div>
<div>&nbsp;</div>
<div>I like binary serialization at the moment.</div>
<div>&nbsp;</div>
<div><a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatter.aspx">http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatter.aspx</a></div>
<div>&nbsp;</div>
<div>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).&nbsp; Json is certainly better IMHO than XML. The binary / cross-platform binary options are more suited to my purposes.&nbsp; </div>

<div>&nbsp;</div>
<div>Under .net Json / Binary / Soap serialization works just about the same way.</div>
<div>&nbsp;</div>
<div><a href="http://pietschsoft.com/post/2008/02/NET-35-JSON-Serialization-using-the-DataContractJsonSerializer.aspx">http://pietschsoft.com/post/2008/02/NET-35-JSON-Serialization-using-the-DataContractJsonSerializer.aspx</a></div>

<div>
<br>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).&nbsp; Tag it up&nbsp;/ decorate it correctly, and job done.&nbsp; Step two, see if Rabbit handles it faithfully (it does for me).</div>

<div>&nbsp;</div>
<div>cheers,</div>
<div>-Steven<br>
</div>
<div class="gmail_quote">On 4 January 2011 08:27, Chen Houwu <span dir="ltr">&lt;<a href="mailto:chenhouwu@...">chenhouwu@...</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">Do you mean that .net client has no build-in support for simple data<br>structure?<br>But I have found it should support according to the AMQP 1.0<br>
specification.<br>AMQP is a binary protocol, but json is text.<br>Though I can send binary content after encoding it to BASE64, it is<br>too inefficient.<br><br>It seams as if the python client support array and dictionary<br>
object.....<br><div class="im">
<br>On 2010&#24180;12&#26376;29&#26085;, &#19979;&#21320;6&#26102;47&#20998;, Marek Majkowski &lt;<a href="mailto:maje... <at> gmail.com">maje...@...</a>&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I think you should be using some standardized encoding,<br>
&gt; like for example json.<br>&gt;<br>
</div>&gt; Take a look at this library:<a href="http://james.newtonking.com/pages/json-net.aspxhttp://stackoverflow.com/questions/571168/what-json-library-works-wel." target="_blank">http://james.newtonking.com/pages/json-net.aspxhttp://stackoverflow.com/questions/571168/what-json-library-works-wel.</a>..<br>
&gt;<br>&gt; Cheers,<br>&gt; &nbsp; Marek<br><div>
<div></div>
<div class="h5">&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On Mon, Dec 27, 2010 at 11:22, Chen Houwu &lt;<a href="mailto:chenho...@...">chenho...@...</a>&gt; wrote:<br>&gt; &gt; &nbsp; I am a newbie to rabbitmq, I want to send a message object as<br>
&gt; &gt; following via .net client:<br>&gt;<br>&gt; &gt; &nbsp; public class Message<br>&gt; &gt; &nbsp; &nbsp;{<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public int ID { get; set; }<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public string Name { get; set; }<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public byte[] Binary { get; set; }<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public string[] Infos{get;set;}<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public Dictionary&lt;string,int&gt; CountMap { get; set; }<br>&gt; &gt; &nbsp; &nbsp;}<br>&gt;<br>&gt; &gt; Here is my code:<br>&gt; &gt; -------------------------------------------<br>
&gt; &gt; var builder = new<br>&gt; &gt; RabbitMQ.Client.Content.StreamMessageBuilder(_channel);<br>&gt; &gt; builder.writeObject(msg.ID);<br>&gt; &gt; builder.writeObject(msg.Name);<br>&gt; &gt; /*----------How to deal with msg.Infos and CountMap here?------------/<br>
&gt;<br>&gt; &gt; /*shoud it be written by myself such as: */<br>&gt; &gt; builder.writeObject(infos.count)<br>&gt; &gt; foreach(var info in infos)<br>&gt; &gt; {<br>&gt; &gt; &nbsp; builder.writerObject(info)<br>&gt; &gt; }<br>
&gt; &gt; /* or the suporting to array and dictionary already exists?*/<br>&gt;<br>&gt; &gt; /* I have found in"src/client/impl/WireFormatting.cs"&#65292; there are<br>&gt; &gt; methods like "WriteArray", and "WriteTable"*/<br>
&gt;<br>&gt; &gt; &nbsp;IBasicProperties props = _channel.CreateBasicProperties();<br>&gt; &gt; props.DeliveryMode = 2;<br>&gt; &gt; &nbsp;_channel.BasicPublish(_exchangeName, "some key", props,<br>&gt; &gt; builder.GetContentBody());<br>
&gt; &gt; -----------------<br>&gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; rabbitmq-discuss mailing list<br>
</div>
</div>&gt; &gt; <a href="mailto:rabbitmq-disc...@...">rabbitmq-disc...@...</a><br><div class="im">&gt; &gt;<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>&gt;<br>&gt; _______________________________________________<br>
&gt; rabbitmq-discuss mailing list<br>
</div>&gt; rabbitmq-disc...@...bitmq.comhttps://<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br><div>
<div></div>
<div class="h5">_______________________________________________<br>rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@...q.com">rabbitmq-discuss@...</a><br><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
Chen Houwu | 4 Jan 12:25 2011
Picon

Re: how to send a message including a array via .net client?

Thanks for all the above answers.

I studied the AMQP 0.9.1 and AMQP 1.0 specification, and found:

in 0.9.1:  only  opaque binary message content (here means the
*playload*) is supported.

but in 1.0 :  message content can be one of the following data type
A. opaque binary data: note, in particular, that the section is not an
instance of the AMQP binary type).
B. amqp-data: zero or more encoded AMQP values)
C. amqp-map: zero length or consist of a single encoded instance of an
AMQP map.
D. amqp-list: zero length or consist of a single encoded instance of
an AMQP list.

RabbitMQ's .net Client is supporting up to AMQP 0.9.1, so message
content does not support those data types other than opaque binary.

AMQP 1.0 has contained it's one message content format similar to JSON
and Protocol Buffer.
Cameron Harris | 4 Jan 18:35 2011

.NET client Subscription constructor not using noAck parameter

Hi,

I think there's a bug in the Subscription class in the .NET client (http://hg.rabbitmq.com/rabbitmq-dotnet-client/file/43c71543a9f9/projects/client/RabbitMQ.Client/src/client/messagepatterns/Subscription.cs).

On line 137, it appears that the constructor is not using the noAck parameter. Therefore, when calling BasicConsume, the noAck parameter is always its default value (false), which also contradicts the documentation for the class. I guess it's missing a m_noAck = noAck.


Thanks,
Cameron Harris

<div><p>Hi,<br><br>I think there's a bug in the Subscription class in the .NET client (<a href="http://hg.rabbitmq.com/rabbitmq-dotnet-client/file/43c71543a9f9/projects/client/RabbitMQ.Client/src/client/messagepatterns/Subscription.cs">http://hg.rabbitmq.com/rabbitmq-dotnet-client/file/43c71543a9f9/projects/client/RabbitMQ.Client/src/client/messagepatterns/Subscription.cs</a>). <br><br>On line 137, it appears that the constructor is not using the noAck parameter. Therefore, when calling BasicConsume, the noAck parameter is always its default value (false), which also contradicts the documentation for the class. I guess it's missing a m_noAck = noAck.<br><br><br>Thanks,<br clear="all">Cameron Harris<br></p></div>

Gmane