How to return ACK from consumer as soon as message is received/consumed?

I am using nameko.messaging.consume for consuming messages from a queue. Here’s a sample code -

from kombu import Queue
from nameko.messaging import consume

class Service:
    name = "sample_service"
    QUEUE = Queue("queue_name", no_declare=True)

    @consume(QUEUE)
    def process_message(self, payload):
        # Some long running code ...
        return result

By default behaviour, ACK will be sent to rabbitMQ broker after process_message function returns a response (Here, statement return result). I want to send an ACK as soon as consumer consumes the message. How can I do that?

*In library “pika”, consumer acknowledges as soon as message is consumed. That will be good example what I want to replicate with nameko’s consumer.

Thanks :blush: @mattbennett