<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Tahoma}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
.MsoChpDefault
        {}
@page Section1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.Section1
        {}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">Hi Mustafa,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">&nbsp;</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">Thanks for your help&#8230;</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">&nbsp;</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">Infact, I need an asynchronous version only so that my code doesn&#8217;t keep on polling the server for new messages..</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">&nbsp;</span></p>
<div style="border:none; border-bottom:solid windowtext 1.0pt; padding:0in 0in 1.0pt 0in">
<p class="MsoNormal" style="border:none; padding:0in"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">My query is, if we have done something like this:</span></p>
<p class="MsoNormal" style="border:none; padding:0in"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">&nbsp;</span></p>
</div>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in; text-autospace:none">
<b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">boolean</span></b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;"> autoAck =
<b>false</b>;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.<i>out</i>.println(&quot;fetching message from the Q: &quot; &#43; queueName &#43; &quot;\n&quot;);
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>this</b>.channel.basicConsume(queueName, autoAck, <b>this</b>.queueingConsumer);&nbsp;&nbsp;
<span style="color:red">// We are trying to fetch the data from the specified queue name
<b>only</b></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueueingConsumer.Delivery delivery;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>try</b> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delivery =
<b>this</b>.queueingConsumer.nextDelivery(timeout);&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:red">//Shouldn&#8217;t this fetch the data from the specified queue only and not some other queue(s); FYI, the same channel has been bound to a no. of queues; I hope this is not the culprit???</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:red">&nbsp;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<b>catch</b> (InterruptedException ie) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>return</b> <b>null</b>;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>if</b>(delivery != <b>null</b>)</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; channel.basicAck(delivery.getEnvelope().getDeliveryTag(),
<b>false</b>);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>byte</b>[] body = delivery.getBody();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>return</b> body;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>else</b></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>return</b> <b>null</b>;</span></p>
<div style="border:none; border-bottom:solid windowtext 1.0pt; padding:0in 0in 1.0pt 0in">
<p class="MsoNormal" style="border:none; padding:0in"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">&nbsp;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">Since, in &#8220;channel.basicConsume&#8221;, I have passed the name of the queue from which data has to be fetched (and not other queues too to which the channel is bound to),
 the why do we get data from other queues too when we do &#8220;</span><b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">this</span></b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">.queueingConsumer.nextDelivery(timeout);<span style="color:black">&#8221;.</span></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">&nbsp;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">Initially, I had used &#8220;basicGet&#8221;, but that will be synchronous and that&#8217;s the reason why I decided to use &#8220;basicConsume&#8221;.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">&nbsp;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:black">Please also see my comments in
</span><b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:red">&#8220;RED&#8221;.</span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:red">&nbsp;</span></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">Also, you can see a trimmed down version of my code here:</span></p>
<p class="MsoNormal"><a href="http://pastebin.com/zLJpUFHA">http://pastebin.com/zLJpUFHA</a></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;">&nbsp;</span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:&quot;Courier New&quot;; color:red">&nbsp;</span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">Thanks &amp; Regards,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">Kamal</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; color:#1F497D">&nbsp;</span></p>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt; font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rabbitmq-discuss-bounces@lists.rabbitmq.com [mailto:rabbitmq-discuss-bounces@lists.rabbitmq.com]
<b>On Behalf Of </b>Amr Mostafa<br>
<b>Sent:</b> Monday, April 11, 2011 7:32 PM<br>
<b>To:</b> Kamal<br>
<b>Cc:</b> rabbitmq-discuss@lists.rabbitmq.com<br>
<b>Subject:</b> Re: [rabbitmq-discuss] data being fetched from other queues too(that are not named in basicConsume)</span></p>
</div>
<p class="MsoNormal">&nbsp;</p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Kamal,<br>
<br>
It looks like you are mistaking Channel.basicConsume for Channel.basicGet. The first (which you are using) is asynchronous and what it does is subscribe a consumer with the messaging server on a given queue. All incoming messages to do that queue will be directly
 sent by the messaging server to that subscribed consumer. In the QueuingConsumer implementation, those received messages are held in an internal queue and you fetch them using nextDelivery.<br>
<br>
This model is called subscription-based, another simpler approach is using Channel.basicGet. I advise you to check this for details:<br>
<br>
<a href="http://www.rabbitmq.com/api-guide.html" target="_blank">http://www.rabbitmq.com/api-guide.html</a></p>
<div>
<p class="MsoNormal">On Mon, Apr 11, 2011 at 3:19 PM, Kamal &lt;<a href="mailto:kamal.nandan@gmail.com" target="_blank">kamal.nandan@gmail.com</a>&gt; wrote:</p>
<p class="MsoNormal">Hi,<br>
<br>
I am facing a strange problem while using RabbitMq.<br>
<br>
I have a consumer that creates 3 queues(just for name sake HIGH/MEDIUM/<br>
LOW priority queues) on the RabbitMQ server and consumes data from the<br>
3 queues in this order:<br>
5 messages from HIGH<br>
3 messages from MEDIUM<br>
2 messages from LOW.<br>
<br>
This keeps on happening in round-robin fashion.<br>
If there is no data available on the respective queue, the data from<br>
the next queue is fetched.<br>
<br>
I am using &quot;Channel.basicConsume(queueName, ACK, QueueingConsumer)&quot;<br>
and &quot;QueueingConsumer.nextDelivery(timeout)&quot; to fetch the data.<br>
<br>
What I see here is: I see that the data is fetched from the other<br>
queues too. i.e. Even though I have passed the queuename as &quot;HIGH&quot;,<br>
then too i see that the data is being fetched from the queue &quot;LOW&quot; or<br>
&quot;MEDIUM&quot; and vice versa. I am finding this behaviour quite strange.<br>
Can someone plz help me out with this.<br>
<br>
Following is a snippet of my code.:<br>
<a href="http://pastebin.com/s03dP91z" target="_blank">http://pastebin.com/s03dP91z</a><br>
<br>
Thanks in advance..<br>
<br>
Regards,<br>
<span style="color:#888888">Kamal<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</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></span></p>
</div>
<p class="MsoNormal">&nbsp;</p>
</div>
</div>
<p class="MsoNormal"><br clear="all">
<br>
-- <br>
Amr Mostafa<br>
Egypt Development Center<br>
Member of NTG<br>
Mobile: &#43;(2012)1700502<br>
Office: &#43;(202)24052355/6 - Ext.: 2005</p>
</div>
</div>
<br>
<hr>
<font face="Verdana" color="Gray" size="1"><br>
Are you exploring a Big Data Strategy ? Listen to this recorded webinar on Planning your Hadoop/ NoSQL projects for 2011 at www.impetus.com/featured_webinar?eventid=37
<br>
<br>
Follow us on www.twitter.com/impetuscalling or visit www.impetus.com to know more.
<br>
<br>
<br>
NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email
 is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.<br>
</font>
</body>
</html>