Skip to content

Add SkipEnqueue to let middleware skip enqueueing a message - #890

Open
ChrisJr404 wants to merge 1 commit into
Bogdanp:masterfrom
ChrisJr404:skip-enqueue-middleware
Open

Add SkipEnqueue to let middleware skip enqueueing a message#890
ChrisJr404 wants to merge 1 commit into
Bogdanp:masterfrom
ChrisJr404:skip-enqueue-middleware

Conversation

@ChrisJr404

Copy link
Copy Markdown

Closes #276.

This adds a SkipEnqueue middleware error. When a middleware raises it from its before_enqueue hook, the broker returns the message without publishing it, so a middleware can stop an enqueue (for example, to drop a message that is already on the queue) without having to override enqueue itself.

It's handled in all three brokers (stub, Redis, RabbitMQ), and after_enqueue is not emitted when a message is skipped. There are tests for each broker plus docs for the new exception and the before_enqueue behaviour.

@ChrisJr404
ChrisJr404 force-pushed the skip-enqueue-middleware branch from 6060e36 to aba494d Compare August 25, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Considering handling a SkipEnqueue MiddlewareError

1 participant