Skip to content

Cancel the consumer before requeueing a refused delivery, require a true handler result - #145

Merged
samdark merged 1 commit into
masterfrom
refused-delivery-cancel-first
Nov 1, 2026
Merged

samdark merged 1 commit into
masterfrom
refused-delivery-cancel-first

Conversation

@samdark

@samdark samdark commented Oct 29, 2026

Copy link
Copy Markdown
Member

Follow-up to #143.

  • When the handler refuses a delivery, Adapter::subscribe() now cancels the consumer first and requeues the delivery after that. Before, the delivery was requeued while the consumer was still registered, so the broker could deliver it straight back to the stopping consumer, where it stayed unacknowledged until the channel was closed.
  • A delivery is treated as handled only when the handler returns true, as the callable(MessageInterface): bool contract says and as InMemoryAdapter in yiisoft/queue does. ExistingMessagesConsumer acknowledged any truthy result but stopped unless it was true; with strict_types a non-boolean result failed there with a TypeError. Both now requeue such a delivery and stop.

…true` handler result

- `Adapter::subscribe()` cancels the consumer before it nacks the refused delivery, so the broker doesn't deliver the
  requeued message to the consumer that is stopping.
- A delivery counts as handled only when the handler returns `true`, in both `Adapter::subscribe()` and
  `ExistingMessagesConsumer`.
@samdark
samdark merged commit 73efab7 into master Nov 1, 2026
22 of 25 checks passed
@samdark
samdark deleted the refused-delivery-cancel-first branch November 1, 2026 13:02
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.

2 participants