Re-prioritize items in a rabbitMq priority queue

1,291 views
Skip to first unread message

JJ Baird

unread,
Sep 10, 2015, 9:26:52 AM9/10/15
to rabbitmq-users
Is there a way to re prioritize items that are already in a RabbitMQ priority queue? Some messages cannot be processed immediately therefore my program responds with a  BasicNack and the message is re-queued. However the re-queued message is retrieved next time the Dequeue command is called. Is there a way to re-prioritize the item to the bottom before/after I call the Nack, so that I could continue with other requests until my program is ready to process that request?

Alvaro Videla

unread,
Sep 10, 2015, 9:31:45 AM9/10/15
to rabbitm...@googlegroups.com
Hi,

basic.nack accepts 3 arguments: message delivery tag, the multiple flag, and the requeue flag. So no, out of the box this is not possible.

Regards,

Alvaro

On Thu, Sep 10, 2015 at 2:26 PM, JJ Baird <jjba...@gmail.com> wrote:
Is there a way to re prioritize items that are already in a RabbitMQ priority queue? Some messages cannot be processed immediately therefore my program responds with a  BasicNack and the message is re-queued. However the re-queued message is retrieved next time the Dequeue command is called. Is there a way to re-prioritize the item to the bottom before/after I call the Nack, so that I could continue with other requests until my program is ready to process that request?

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Derick Bailey

unread,
Sep 10, 2015, 10:02:00 AM9/10/15
to rabbitm...@googlegroups.com
if you set up a dead letter exchange and re-route the message back to the same queue that would push the message in the back of the queue, i think 

the delayed message exchange type may also be useful here, if you know that you want to delay processing for a particular period of time...

either way, you would have to write a bit more code to make this work the way you want

Laing, Michael

unread,
Sep 10, 2015, 11:06:29 AM9/10/15
to rabbitm...@googlegroups.com
If you want to alter the priority of the message, you can nack it (requeue=false) to the DLX as Derick described, then use a static shovel to set the priority via the shovel configuration and requeue it to your priority queue:

publish_properties [clause]
 
By default the properties of the message are preserved, but this clause can be used to change, or set any property, including content_typecontent_encodingheadersdelivery_modepriority,correlation_idreply_toexpirationmessage_idtimestamptypeuser_idapp_id andcluster_id.


No code. Just configuration.

ml
 

JJ Baird

unread,
Sep 11, 2015, 10:52:51 AM9/11/15
to rabbitmq-users
Thank you Michael and Derrick!!

I created a queue with DLX and a shovel. Didn't even need to change priority. The time it takes to reroute the message from the DLX back to the queue is more than enough time for other requests that are waiting to be processed. It works like a charm! Now I just need to create a shovel in code, is that possible?
Reply all
Reply to author
Forward
0 new messages