1
votes

MassTransit exposes functions for adding queue and exchange arguments, but I cannot find anything similar for the consumer.

I would like to be able to set the priority of consumers (x-priority argument) per the RabbitMQ documentation here: https://www.rabbitmq.com/consumer-priority.html

Is that possible using MassTransit?

2
I just pushed this to develop, should be in the next release.Chris Patterson

2 Answers

2
votes

It should be easy enough to add this to MT, I'll create an issue on GitHub.

1
votes

According to RabbitMQ documentation:

Set the x-priority argument in the basic.consume method to an integer value. Consumers which do not specify a value have priority 0. Larger numbers indicate higher priority, and both positive and negative numbers can be used.

When you setup consumer you can use ConsumerPriority in this case to set a lower priority

_busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
{
    IRabbitMqHost host = cfg.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
    {
        h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
        h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
    });

    cfg.ReceiveEndpoint(host, "Audit", e =>
    {
        e.PrefetchCount = 2;
        e.ConsumerPriority = -1;
        e.Consumer<AuditConsumer>();
    });
});

Rabbit Consumer