Skip to content

Messages might not be acked when shutting down on rabbit #148

Closed
@davidt99

Description

@davidt99

Since dramatiq 1.3 the messages are acked in the background using add_callback_threadsafe, I had few times where a message should have been acked but the background thread didn't have the changes to run.
One solution is to switch to synchronous ack, or call connection.sleep(1) when the closing the connection (kinda hacky).

To reproduce, add this middleware to rabbitmq broker and send any message. When shutting down, most of the time both the delay queue and the default queue will have the same message:

class RetryMiddleware(dramatiq.middleware.Middleware):
    def after_process_message(self, broker, message, *, result=None, exception=None):
        broker.enqueue(message, delay=1000)

As a side note, overriding the relevant methods (ack, nack and close) wasn't convenient since the rabbit consumer is private and the broker doesn't have consumer class parameter, only consume method.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions