Rabbit MQ Prefetch Configuration On IMessageService RegisterHandler

Can someone provide an example of how to set the prefetch setting in the Rabbit MQ client? I found this thread and can verify the PR has indeed made this setting configurable. I am using version 5.5, but I am unable to configure the prefetch. Is there a unit test or an example that can be provided?

The PrefetchCount property @DeonHeyns added was added to the RabbitMqProducer class which you can modify by casting either the IMessageProducer or IMessageQueueClient clients to RabbitMqProducer where you can set the property directly, e.g:

using (var mqProducer = mqFactory.CreateMessageProducer())
{
    var rabbitMqProducer = (RabbitMqProducer) mqProducer;
    rabbitMqProducer.PrefetchCount = 10;
}

using (var mqClient = mqFactory.CreateMessageQueueClient())
{
    var rabbitMqProducer = (RabbitMqProducer) mqClient;
    rabbitMqProducer.PrefetchCount = 10;
}

Is there anyway to set this when consuming from a handler?

Not sure if by handler you mean modifying the MQ Client used to process RabbitMqServer messages, but I’ve just added a MqQueueClientFilter and MqProducerFilter in this commit which will let you modify all MQ Clients retrieved from the message factory, which you can configure with:

new RabbitMqServer(....) {
    MqQueueClientFilter = client => client.PrefetchCount = 10
}

This change is available from v5.5.1 that’s now available on MyGet.