Delayed consumption or delayed dispatching of a rabbitmq message

#1

rabbitmq-delayed-message-exchange

Is there any planning to support this rabbitmq feature? I tried looking in the https://github.com/nameko/nameko/blob/master/nameko/messaging.py but couldn’t find anything that allows delayed consumption of a rabiitmq message.

0 Likes

#2

You can already use this plugin in conjunction with Nameko’s Publisher DependencyProvider.

First you’d declare an exchange as type=x-delayed-message, then use the x-delay header when publishing. Something like this:

from kombu.messaging import Exchange

exchange = Exchange(type="x-delayed-message")

class Service:
    name = "delayed_message"

    publish = Publisher(exchange=exchange, headers={"x-delay": 100})  # default delay

    def method(self, delay):
        self.publish("payload", ..., headers={"x-delay": delay})  # override delay
0 Likes