MassTransit公开了添加队列和交换参数的函数,但我找不到任何类似的消费者。
我希望能够根据RabbitMQ文档设置使用者的优先级(x-priority参数):https://www.rabbitmq.com/consumer-priority.html
可以使用MassTransit吗?
根据RabbitMQ文档:
将basic.consume方法中的x-priority参数设置为整数值。未指定值的消费者具有优先级0.较大的数字表示较高的优先级,并且可以使用正数和负数。
设置使用者时,您可以在这种情况下使用ConsumerPriority来设置较低的优先级
_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>();
});
});
将它添加到MT应该很容易,我将在GitHub上创建一个问题。