<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:"Calibri","sans-serif"; color:#1F497D">Hi Mustafa,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Thanks for your help…</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Infact, I need an asynchronous version only so that my code doesn’t keep on polling the server for new messages..</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </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:"Calibri","sans-serif"; 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:"Calibri","sans-serif"; color:#1F497D"> </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:"Courier New"">boolean</span></b><span style="font-size:10.0pt; font-family:"Courier New""> autoAck =
<b>false</b>;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> System.<i>out</i>.println("fetching message from the Q: " + queueName + "\n");
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>this</b>.channel.basicConsume(queueName, autoAck, <b>this</b>.queueingConsumer);
<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:"Courier New"; color:red">
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> QueueingConsumer.Delivery delivery;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>try</b> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> delivery =
<b>this</b>.queueingConsumer.nextDelivery(timeout); <span style="color:red">//Shouldn’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:"Courier New"; color:red"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> }
<b>catch</b> (InterruptedException ie) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>return</b> <b>null</b>;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>if</b>(delivery != <b>null</b>)</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> 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:"Courier New"">
<b>byte</b>[] body = delivery.getBody();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>return</b> body;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<b>else</b></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New""> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"">
<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:"Courier New""> }</span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Since, in “channel.basicConsume”, 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 “</span><b><span style="font-size:10.0pt; font-family:"Courier New"">this</span></b><span style="font-size:10.0pt; font-family:"Courier New"">.queueingConsumer.nextDelivery(timeout);<span style="color:black">”.</span></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Initially, I had used “basicGet”, but that will be synchronous and that’s the reason why I decided to use “basicConsume”.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Please also see my comments in
</span><b><span style="font-size:10.0pt; font-family:"Courier New"; color:red">“RED”.</span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:"Courier New"; color:red"> </span></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"">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:"Courier New""> </span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:"Courier New"; color:red"> </span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Thanks & Regards,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Kamal</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </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:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif""> 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"> </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 <<a href="mailto:kamal.nandan@gmail.com" target="_blank">kamal.nandan@gmail.com</a>> 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 "Channel.basicConsume(queueName, ACK, QueueingConsumer)"<br>
and "QueueingConsumer.nextDelivery(timeout)" 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 "HIGH",<br>
then too i see that the data is being fetched from the queue "LOW" or<br>
"MEDIUM" 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"> </p>
</div>
</div>
<p class="MsoNormal"><br clear="all">
<br>
-- <br>
Amr Mostafa<br>
Egypt Development Center<br>
Member of NTG<br>
Mobile: +(2012)1700502<br>
Office: +(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>