Event_handler is timer based


Just wonder is there a special directive that we can configure event_handler to consume message periodically

@event_handler(‘serviceA’,‘queueA’, timer=60s)
def polling(self, dummy_data):
statement a
result = check_status()
if not result:

As you can see, the event handler will consume one message at a time from queueA every 60 seconds.

Currently, i use this logic, there will be a recursive firing of alot of events till check_status return false. What we do not want is to implement a database logic in order to support this.

Any help will be useful

I’m not sure I understand the question.

event_handler does not accept a timer argument, and it is not possible to do “periodic consumes” – the consumer will grab messages as soon as they are available on the queue.

But there is possibly a way to get the behaviour you want if you restrict your entrypoint to consume a single message at a time (using the prefetch_count argument), and an insert a delay in the service method.

class Service:
    @event_handler("serviceA", "queueA", prefetch_count=1):
    def poll(self, event_data):

This will print the data from an event every 60 seconds.

You need to use the Nameko 3.x prerelease (pip install --pre nameko) because the prefetch_count argument is only exposed there.

Thanks matt… yes, what we need is

periodic consumes

Sounds like it is not possible for now without create a persistent table/app logic for a internal queue. I tot it would be easier to use rabbit as it is already a queue