java - RabbitMQ Prefetch Ignored -


i'm running problem setting basic.qos 1 doesn't have desired effect - tons of messages still pushed consumer.

my code looks little this:

    channel channel = getchannel("pollqueuepassive"); // our own channel pool implementation      try{         channel.queuedeclarepassive(queue.name);     } catch (ioexception e){         channel = getchannel("pollqueueactive");         channel.queuedeclare(queue.name, true, false, false, null);     }      channel.basicqos(1);      queueingconsumer consumer = new queueingconsumer(channel);     channel.basicconsume(queue.name, autoack, consumer);      while (!stoppolling()) {          try{               queueingconsumer.delivery delivery = consumer.nextdelivery();               string message = new string(delivery.getbody());                boolean workresult = dowork(message);               if(!autoack) {                   if(workresult)                        channel.basicack(delivery.getenvelope().getdeliverytag(), true);                   else                       channel.basicnack(delivery.getenvelope().getdeliverytag(), false, true);               }              } catch (interruptedexception e) {}     }      closeconnection(); 

as begin consume queue in way, messages in queue (upwards of 20,000, in cases) instantly delivered consumer. since i'd distribute messages in queue dozens of consumers simultaneously, behavior undesirable. i've played moving basic.qos declaration around - including before returning channel our channel pool - no avail. ideas why prefetch size wouldn't honored?

thanks!

from official doc:

the prefetch-count ignored if no-ack option set.

and looks using auto-ack flag consumer. sure check value of autoack variable.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -