Skip to content

PikaTransport: Re-enable publisher confirms - #220

Merged
ndevenish merged 1 commit into
mainfrom
pika-publisher-confirms
Nov 6, 2026
Merged

ndevenish merged 1 commit into
mainfrom
pika-publisher-confirms

Conversation

@ndevenish

@ndevenish ndevenish commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Non-transactional sends now go through a dedicated channel in publisher-confirms mode, so basic_publish blocks until the broker acknowledges the message, and raises UnroutableError/NackError if it is rejected. Confirm and transaction modes are mutually exclusive on a channel, so the shared channel is kept in plain mode for transactions not tied to a subscription.

Broker rejections are now delivered to the caller's future only, rather than also being raised into the connection runloop, which would otherwise terminate the thread without reconnecting.

Since PikaTransport.send uses mandatory=True, sending to a queue that does not exist now raises instead of silently dropping the message.

Note on testing

This also fixes a race in test_pikathread_send_named_exchange. Without confirms, send().result() returns as soon as the message is written to the socket, so the test's immediate basic_get on a separate connection can run before the broker has routed the message. Against a real broker the test fails reliably when run on its own (15/15 runs on main, 0/15 with this change).

This has never been caught because CI provides no RabbitMQ, so every test that needs a broker is skipped (14 skipped in this PR's CI run too). #221, stacked on this PR, adds a broker to CI and a local fixture that starts one in a container. With both applied the suite passes with nothing skipped: 183 passed, 3 xfailed.

Fixes #96

@ndevenish
ndevenish added this pull request to stack #222 November 6, 2026 16:25
@ndevenish
ndevenish force-pushed the pika-publisher-confirms branch from e70522a to 79224d6 Compare November 6, 2026 16:38
Non-transactional sends now go through a dedicated channel in
publisher-confirms mode, so basic_publish blocks until the broker
acknowledges the message, and raises UnroutableError/NackError if
it is rejected. Confirm and transaction modes are mutually exclusive
on a channel, so the shared channel is kept in plain mode for
transactions not tied to a subscription.

Broker rejections are now delivered to the caller's future only,
rather than also being raised into the connection runloop, which
would otherwise terminate the thread without reconnecting.

Since PikaTransport.send uses mandatory=True, sending to a queue
that does not exist now raises instead of silently dropping the
message.

Fixes #96
@ndevenish
ndevenish force-pushed the pika-publisher-confirms branch from 79224d6 to 19e1efb Compare November 6, 2026 16:52
@ndevenish
ndevenish merged commit e95912c into main Nov 6, 2026
8 checks passed
@ndevenish
ndevenish deleted the pika-publisher-confirms branch November 6, 2026 16:55
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.

PikaTransport: Re-enable Publisher Confirms mode

1 participant