ProIcons
ProIcons
CC#
Created by ProIcons on 7/9/2023 in #help
❔ [RabbitMQ][RabbitMq.Client] Low consuming rate.
Have anybody worked with RabbitMQ.Client ? I have this connection factory
.AddSingleton<IAsyncConnectionFactory, ConnectionFactory>(x =>
{
return new ConnectionFactory
{
DispatchConsumersAsync = true,
ConsumerDispatchConcurrency = 10,
// UseBackgroundThreadsForIO = true,
UserName = config.Username,
Password = config.Password,
HostName = config.Host,
Port = config.Port,
Ssl = config.SSL
? new SslOption(config.Host, enabled: true)
: new SslOption()
};
})
.AddSingleton<IAsyncConnectionFactory, ConnectionFactory>(x =>
{
return new ConnectionFactory
{
DispatchConsumersAsync = true,
ConsumerDispatchConcurrency = 10,
// UseBackgroundThreadsForIO = true,
UserName = config.Username,
Password = config.Password,
HostName = config.Host,
Port = config.Port,
Ssl = config.SSL
? new SslOption(config.Host, enabled: true)
: new SslOption()
};
})
and then i'm doing something like this:
public class A : AsyncDefaultBasicConsumer
{
public A(IModel model) : base(model)
{
}

public override Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
IBasicProperties properties, ReadOnlyMemory<byte> body)
{
return Task.CompletedTask;
}
}

using var connection = _connectionFactory.CreateConnection();
var channel = connection.CreateModel();
var consumer = new A(channel);
channel.BasicConsume(consumer, queueInfo.Name, autoAck: false, exclusive: true);
public class A : AsyncDefaultBasicConsumer
{
public A(IModel model) : base(model)
{
}

public override Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
IBasicProperties properties, ReadOnlyMemory<byte> body)
{
return Task.CompletedTask;
}
}

using var connection = _connectionFactory.CreateConnection();
var channel = connection.CreateModel();
var consumer = new A(channel);
channel.BasicConsume(consumer, queueInfo.Name, autoAck: false, exclusive: true);
Effectively i'm just consuming messages without acknowledging them. The consume rate is about 50/s. And it seems like it is hard capped there. Other tools can achieve from the same computer, same network, same remote rabbitmq, up to 400/s. Any ideas why i get such poor consuming rate ?
8 replies