Merge pull request 'v2' (#422) from eithday/Admin.NET.Pro:v2 into v2
Reviewed-on: https://code.adminnet.top/Admin.NET/Admin.NET.Pro/pulls/422
This commit is contained in:
commit
0ecf99ba1a
@ -21,15 +21,16 @@ public class RabbitMqConsumer : BackgroundService
|
||||
}
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
var channel = _connection.Channel;
|
||||
if (channel == null)
|
||||
throw new InvalidOperationException("RabbitMQ channel is null");
|
||||
|
||||
if (!await _connection.TryConnectAsync())
|
||||
{
|
||||
_logger.LogError($"RabbitMQ连接失败,请检查配置文件。");
|
||||
return;
|
||||
}
|
||||
|
||||
var channel = _connection.Channel;
|
||||
if (channel == null)
|
||||
throw new InvalidOperationException("RabbitMQ channel is null");
|
||||
|
||||
await channel.QueueDeclareAsync(queue: _handler.QueueName, durable: true, exclusive: false, autoDelete: false, arguments: null);
|
||||
await channel.BasicQosAsync(prefetchSize: 0, prefetchCount: 1, global: false);
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user