java - How to Prevent Spring AMQP from Blocking on Unacked Messages? -
i have @rabbitlistener
annotated method spring amqp blocks after returning method. underlying simplerabbitlistenercontainerfactory
uses acknowledgemode.manual
. don’t want acknowledge message in listener method, yet.
is there way not have spring amqp block in such scenario?
in more detail
i use listener this:
@rabbitlistener(queues = "#{ @myqueue }") void recordrequestsfrommymessages( @payload mymessage mymessagepayload, @header(amqpheaders.delivery_tag) long deliverytag, channel channel) { // record relevant parts of given message , combine them // parts previous/future messages // don't acknowledge consumed message, yet; instead keep // record of channel , delivery tag }
since batch/combine multiple messages before process them (asynchronously) later, don’t want acknowledge consumed message right away. instead, want once messages have been processed later.
with current approach, spring amqp blocks after returning calling recordrequestsfrommymessages
method above , no further messages consumed same queue anymore.
this answer suggests batch processing should work, however, i’m not sure how.
it's not container that's "blocking".
you need increase prefetchcount
on container (default 1) - broker allows number of unacked messages outstanding.
Comments
Post a Comment