<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m currently trying to setup RabbitMQ for my company and we have 1 publisher pushing to 1 queue, pretty simple so far. <o:p></o:p></p><p class=MsoNormal>But we have lots of consumers, potentially up to a hundred, reading that queue. Reason being the processing of each of those messages can take a long time.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>To clarify, in our current scenario after processing, the consumer logic requeues the message. The goal is to have a given set of messages being processed over and over again in a cycle.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>We’re using the .Net client library and we quickly favored the consumer approach:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:green'>QueueingBasicConsumer consumer = new QueueingBasicConsumer(this.channel);</span><span style='font-size:9.0pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:green'>string consumerTag = this.channel.BasicConsume(this.queueName, noAck, consumer);</span><span style='font-size:9.0pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>But we ran into issues where the messages were getting dropped. I payed attention to make sure we were doing the necessary ACK and/or NACK to make sure a message always gets processed.<o:p></o:p></p><p class=MsoNormal>After a while I decided that my implementation was flawed somewhere, so for a test I simplified the code and started using the Subscription object:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:#2B91AF'>Subscription</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> subscription = </span><span style='font-size:9.0pt;font-family:Consolas;color:blue'>new</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> </span><span style='font-size:9.0pt;font-family:Consolas;color:#2B91AF'>Subscription</span><span style='font-size:9.0pt;font-family:Consolas;color:black'>(</span><span style='font-size:9.0pt;font-family:Consolas;color:blue'>this</span><span style='font-size:9.0pt;font-family:Consolas;color:black'>.channel, </span><span style='font-size:9.0pt;font-family:Consolas;color:blue'>this</span><span style='font-size:9.0pt;font-family:Consolas;color:black'>.queueName, </span><span style='font-size:9.0pt;font-family:Consolas;color:blue'>false</span><span style='font-size:9.0pt;font-family:Consolas;color:black'>);<o:p></o:p></span></pre><p class=MsoNormal><o:p> </o:p></p><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:blue'>foreach</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> (</span><span style='font-size:9.0pt;font-family:Consolas;color:#2B91AF'>BasicDeliverEventArgs</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> e </span><span style='font-size:9.0pt;font-family:Consolas;color:blue'>in</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> subscription)<o:p></o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:black'>{<o:p></o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:blue'> if</span><span style='font-size:9.0pt;font-family:Consolas;color:black'> (!e.Redelivered)<o:p></o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:black'> …<o:p></o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:black'>}<o:p></o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:black'><o:p> </o:p></span></pre><pre style='background:white'><span style='font-size:9.0pt;font-family:Consolas;color:black'><o:p> </o:p></span></pre><p class=MsoNormal>The problem w/ this approach is all our consumers read all the messages…. Instead of just dequeuing in a round-robin fashion.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Could someone point me in the right direction for using RabbitMQ to do a round-robin-like distribution?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Yann<o:p></o:p></p></div></body></html>