Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RabbitMQ] Declare Quorum Queues #94

Open
farlop opened this issue Jan 14, 2022 · 2 comments
Open

[RabbitMQ] Declare Quorum Queues #94

farlop opened this issue Jan 14, 2022 · 2 comments

Comments

@farlop
Copy link

farlop commented Jan 14, 2022

Is there any way of declare a queue as a Quorum Queue in order to be used on a K8s cluster with multiple replicas?

Currently I don't see any way of adding additional arguments to the queue declaration (in QueueOptions). Maybe is something to be added?

@spetz
Copy link
Member

spetz commented Jan 19, 2022

That's a good idea - will check what can be done, and extend the implementation.

@dextermyles
Copy link

dextermyles commented Feb 11, 2023

pretty easy to do.

I extended the RabbitMqOptions.QueueOptions:

public class QueueOptions
    {
        public string Template { get; set; }
        public bool Declare { get; set; }
        public bool Durable { get; set; }
        public bool Exclusive { get; set; }
        public bool AutoDelete { get; set; }
        public Dictionary<string, object> Arguments { get; set; }
    }

Updated RabbitMqBackgroundService.Subscribe:

var queueArguments = deadLetterEnabled
    ? new Dictionary<string, object>
    {
        {"x-dead-letter-exchange", deadLetterExchange},
        {"x-dead-letter-routing-key", deadLetterQueue},
    }
    : new Dictionary<string, object>();

// additional arguments
if (_options.Queue.Arguments != null)
{
    foreach (var key in _options.Queue.Arguments)
    {
        queueArguments.TryAdd(key.Key, key.Value);
    }
}

channel.QueueDeclare(conventions.Queue, durable, exclusive, autoDelete, queueArguments);

Updated appsettings to pass in the quorum queue arguments:

"rabbitMq": {
  "queue": {
    "arguments": {
      "x-queue-type": "quorum"
    }
  }
}

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

No branches or pull requests

3 participants