Skip to content

Declare Mocha's temporary RabbitMQ queues durable with auto-delete and expiry - #10384

Open
alisan3 wants to merge 1 commit into
ChilliCream:mainfrom
alisan3:ali/mocha-rabbitmq-durable-temporary-queues
Open

alisan3 wants to merge 1 commit into
ChilliCream:mainfrom
alisan3:ali/mocha-rabbitmq-durable-temporary-queues

Conversation

@alisan3

@alisan3 alisan3 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

On a RabbitMQ 4.3 broker with default settings, a Mocha host using the RabbitMQ transport cannot start. RabbitMQ 4.3 moved the deprecated feature transient_nonexcl_queues from permitted to denied by default, and the transport declared its per-instance reply queue as non-durable, auto-delete and non-exclusive. The broker refuses that declare with INTERNAL_ERROR - Feature transient_nonexcl_queues is deprecated, MessagingRuntimeHostedService.StartAsync faults and the host exits. Every Temporary() queue had the same shape. The suite did not catch it because the shared Testcontainers image was pinned to rabbitmq:3.11.

Changes

  • Temporary() on the RabbitMQ transport now means durable + auto-delete + x-expires, which the RabbitMQ docs name as the replacement for transient non-exclusive queues. RabbitMQQueue.MarkTemporary no longer clears Durable, the routing strategy stops forcing Durable = false, and the declared-queue conflict check only rejects a queue that is not auto-delete.
  • New Temporary(TimeSpan expiry) overload on IRabbitMQReceiveEndpointDescriptor and IRabbitMQQueueDescriptor, mirroring the Azure Service Bus transport. The default is 30 minutes via RabbitMQReceiveEndpointConfiguration.TemporaryDefaults.Expiry. Non-positive values and values beyond the x-expires integer range throw.
  • Quorum or stream bus defaults still do not reach temporary queues, so the reply queue stays a classic queue.
  • New ThrowHelper for the RabbitMQ transport project.
  • Shared test image bumped from rabbitmq:3.11 to rabbitmq:4.3 in CookieCrumble.Resources.RabbitMQ, so the RabbitMQ suites run against a broker that denies the old shape.
  • Docs: transport mapping table in routing-and-endpoints.md and the temporary endpoints section of transports/rabbitmq.md.

Tests

  • Existing tests that asserted the non-durable shape are rewritten as inline snapshots.
  • New unit tests cover the reply queue shape with and without quorum defaults, a custom expiry, an invalid expiry, and a declared auto-delete queue being accepted with Temporary().
  • New integration test lists the reply queue through rabbitmqctl and pins durable=true, auto_delete=true, exclusive=false, arguments=[{"x-expires",1800000},{"x-queue-type","classic"}].
  • Mocha.Transport.RabbitMQ.Tests: 472 passed against rabbitmq:4.3. HotChocolate.Subscriptions.RabbitMQ.Tests: 8 passed against the same image.

Behavior change

A Temporary() queue with a stable name that still exists on a broker as non-durable fails redeclaration with PRECONDITION_FAILED until its old consumer disconnects and auto-delete removes it. This only matters when an old and a new instance overlap on the same queue name. Reply queues use a fresh name per instance and are unaffected.

…e expiry

RabbitMQ 4.3 denies the deprecated feature transient_nonexcl_queues by
default. Mocha declared its per-instance reply queue, and every other
Temporary() queue, as non-durable, auto-delete and non-exclusive, so the
broker refused the declare and the host failed in
MessagingRuntimeHostedService.StartAsync.

Temporary() now keeps the queue durable and scopes its lifetime through
auto-delete plus an x-expires queue expiry, which RabbitMQ documents as
the replacement for transient non-exclusive queues. The default expiry
is 30 minutes; Temporary(TimeSpan) on the receive endpoint and queue
descriptors sets a custom one. The declared-queue conflict check only
rejects queues that are not auto-delete.

The shared Testcontainers image moves from rabbitmq:3.11 to
rabbitmq:4.3 so the RabbitMQ suites run against a broker with the new
default.
@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ mocha labels Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ mocha

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant