java - How to disable RabbitMQ prefetch count with SimpleMessageListenerContainer -
rabbitmq offers ability optionally set prefetch count.
using spring-amqp's simplemessagelistenercontainer
, i've noticed prefetch count set. cannot set prefetch count 0, because simplemessagelistenercontainer
sets @ least txsize
must greater 0 (even when there no transactions involved). there way disable prefetch count, i.e. make unlimited?
here relevant code spring-amqp:
simplemessagelistenercontainer.createblockingqueueconsumer()
this:
int actualprefetchcount = prefetchcount > txsize ? prefetchcount : txsize;
and blockingqueueconsumer.start()
this:
if (!acknowledgemode.isautoack()) { // set basicqos before calling basicconsume (otherwise if not acking broker // send blocks of 100 messages) try { channel.basicqos(prefetchcount); }
what reasoning behind calling basicqos() in springs's blockingqueueconsumer
? isn't there use case disabling prefetch count? (except auto-ack obviously).
the rabbitmq documentation discusses overhead of setting prefetch count channel (global) scope. not explicitly mentioned whether setting consumer scope has overhead compared not setting @ all. if i'm not mistaken spring sets consumer scope. indeed have no overhead @ all? still seems strange not having option not set it.
thanks
since current implementation hands off internal queue, due way earlier rabbitmq clients worked, not setting qos cause oom condition if consumer can't keep up.
in fact, earlier versions of spring amqp, happen auto ack queue bounded according prefetch size stop broker sending messages under condition.
in 2.0, planning new container implementation avoids queue since rabbit client no longer has issues required it. can consider supporting qos=0 then.
Comments
Post a Comment