Skip to content

add the ability to create internal queues as quorum type instead of hard-coded classic - #80

Merged
nikosd23 merged 11 commits into
masterfrom
option_create_delayed_queues_and_reply_as_quorum
Oct 13, 2026
Merged

nikosd23 merged 11 commits into
masterfrom
option_create_delayed_queues_and_reply_as_quorum

Conversation

@Michalis-Apostolou

@Michalis-Apostolou Michalis-Apostolou commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Need

We need to upgrade the rmq cluster to version 4+. in this version High Availability (HA) policy with mirror queues has been deprecated and completely removed https://www.rabbitmq.com/docs/3.13/ha . So we need to replace all classic queue definitions with quorum

Problem

Rabbit-queue creates internal queues to implement scheduled publishing for a message

  1. there is a queue created on app connect {prefix}_delay_reply
  2. The publisher for a delayed messaged for XXX amount creates the queue {prefix}_delay_{XXX}

Example:
image

Since the library does not define the type of the queue , the are created to what is default on the virtual host.

If can't/don't want to change the default queue type of the virtual host , you should have the ability to define if these queues should be created as quorum or not.

Solution

By utilizing a new option available in the package scheduledPublishQueuesAsQuorum on rabbit config, this will passed around during the creating of the queues.
In order to avoid conflicts between already created classic queues and newly created quorum queues , the naming convention changes to

  1. {prefix}_delay_quorum_reply
  2. {prefix}_delay_quorum_{XXX}
image

Comment thread test/delay-queue.test.ts Outdated

@iliasbibas iliasbibas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to look a bit deeper on how quorum queues handle dead lettering, a policy might be needed if we need the messages to end up in a DLQ instead of silently dropped.

Comment thread ts/rabbit.ts Outdated
@Michalis-Apostolou

Copy link
Copy Markdown
Contributor Author

I think we need to look a bit deeper on how quorum queues handle dead lettering, a policy might be needed if we need the messages to end up in a DLQ instead of silently dropped.

@iliasbibas Are you referring to enable the at-least-once guarantee ? https://www.rabbitmq.com/docs/quorum-queues#activating-at-least-once-dead-lettering. to override the default at-most-once ?

@iliasbibas

Copy link
Copy Markdown

I think we need to look a bit deeper on how quorum queues handle dead lettering, a policy might be needed if we need the messages to end up in a DLQ instead of silently dropped.

@iliasbibas Are you referring to enable the at-least-once guarantee ? https://www.rabbitmq.com/docs/quorum-queues#activating-at-least-once-dead-lettering. to override the default at-most-once ?

Yes, for the delay queues I believe at-least-once and overflow: reject-publish should be set so that the delayed job end up in the delay_reply queue (I think that the delay_reply is already set as the target for these messages).

@iliasbibas

Copy link
Copy Markdown

Btw @Michalis-Apostolou , the _quorum_ addition in the queue name should perhaps be optional right? Otherwise it break compatibility, ie will doubly create queues even if an existing quorum queue without the name addition exists.

Comment thread ts/rabbit.ts
name = this.updateName(name, prefix);
await this.connected;
await publishWithDelay(this.updateName('delay'), obj, properties, this.consumeChannel, name);
const queueName = this.scheduledPublishQueuesAsQuorum ? 'delay_quorum' : 'delay';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 hold the naming order of quorum until SREs verify what regexps are using for alerts on delay queues (cc @a-margaritis )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked Datadog: no monitor names delay queues. The only ones that cover them are SRE's per-queue length catch-all (6080758) and the unacked-rate anomaly monitor (112880512), and both pick up <app>_delay_quorum_* automatically. @a-margaritis, can you confirm there's nothing on the CloudAMQP side (alarms or policies) that matches _delay_ by name? If not, I think the naming hold can be lifted.

@Michalis-Apostolou

Copy link
Copy Markdown
Contributor Author

Btw @Michalis-Apostolou , the _quorum_ addition in the queue name should perhaps be optional right? Otherwise it break compatibility, ie will doubly create queues even if an existing quorum queue without the name addition exists.

it was intentional , because if there was already existing a classic queue with the same name. and you opt-in to create the same queue with different config (i.e. quorum queue type) it will conflict ungracefully and will cause to disconnect.

Then there is the issue on how to resolve such conflict. you can't update a queue config. you have to destroy and recreate the queue. During the recreation of the queue in a high traffic topic may lead to message loss

@iliasbibas

iliasbibas commented Oct 2, 2026 •

Copy link
Copy Markdown

Btw @Michalis-Apostolou , the _quorum_ addition in the queue name should perhaps be optional right? Otherwise it break compatibility, ie will doubly create queues even if an existing quorum queue without the name addition exists.

it was intentional , because if there was already existing a classic queue with the same name. and you opt-in to create the same queue with different config (i.e. quorum queue type) it will conflict ungracefully and will cause to disconnect.

Then there is the issue on how to resolve such conflict. you can't update a queue config. you have to destroy and recreate the queue. During the recreation of the queue in a high traffic topic may lead to message loss

I understand that, I'm saying that in a cluster that already has a quorum queue example_queue (e.g. vhost default) , creating a new example_quorum_queue by default will not be correct.
Also an introduction of new naming conventions will require updating the existing policies, most of which rely on regex.

Michalis-Apostolou and others added 4 commits October 2, 2026 16:28
set overflow and x-dead-letter-strategy to at-least-once for delayed quorum queues and delayed reply queue
…quorum

Keeps both options next to each other: scheduledPublishQueuesAsQuorum from
this PR and tolerateQueueTypeMismatch from #81. 5.10.0 shipped without this
PR, so its changelog entry moves to 5.11.x.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ikarachristos

Copy link
Copy Markdown
Contributor

@iliasbibas revisited the naming now that #81 is merged. #81 only tolerates a queue type or priority mismatch, and only when you opt in. Quorum delay queues also declare x-overflow: reject-publish, which isn't tolerated, so reusing the name would make publishWithDelay fail until each queue is converted. Converting a delay queue in place also re-publishes its messages, which restarts their delays. New names let old and new pods run side by side, and the old queues empty out before we delete them.

Your duplicate case only applies where <app>_delay_<ms> is already quorum. rabbit-queue declares delay queues without a type, so that only happens on a vhost whose default queue type is quorum, and there you can leave the option off.

On policies: none of the policies on the sourcing brokers target delay queues by name. The HA catch-all covers the new names, and quorum queues ignore its ha-* keys.

…amqplib typings

The compiled js/channel.d.ts referenced ../ts/amqplib.d.ts, which is excluded
from the npm package, breaking type checking for consumers without skipLibCheck
(TS6053). Passing x-overflow in the queue arguments needs no typings patch.
The previous test published to 'delay', reusing the delay_10000 queue cached
by an earlier test, so it never declared a quorum queue or checked its name.
@nikosd23
nikosd23 merged commit 67ad7b0 into master Oct 13, 2026
7 checks passed
@nikosd23
nikosd23 deleted the option_create_delayed_queues_and_reply_as_quorum branch October 13, 2026 09:24
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.

6 participants