diff --git a/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs b/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs index 9d372ec52b..3d7e8c05ff 100644 --- a/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs +++ b/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs @@ -21,7 +21,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ protected BackgroundJobConfiguration JobConfiguration { get; } protected JobQueueConfiguration QueueConfiguration { get; } protected IChannelAccessor ChannelAccessor { get; private set; } - protected EventingBasicConsumer Consumer { get; private set; } + protected AsyncEventingBasicConsumer Consumer { get; private set; } public ILogger> Logger { get; set; } @@ -135,7 +135,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ if (AbpBackgroundJobOptions.IsJobExecutionEnabled) { - Consumer = new EventingBasicConsumer(ChannelAccessor.Channel); + Consumer = new AsyncEventingBasicConsumer(ChannelAccessor.Channel); Consumer.Received += MessageReceived; //TODO: What BasicConsume returns? @@ -173,7 +173,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ return properties; } - protected virtual void MessageReceived(object sender, BasicDeliverEventArgs ea) + protected virtual async Task MessageReceived(object sender, BasicDeliverEventArgs ea) { using (var scope = ServiceScopeFactory.CreateScope()) { @@ -185,7 +185,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ try { - AsyncHelper.RunSync(() => JobExecuter.ExecuteAsync(context)); + await JobExecuter.ExecuteAsync(context); ChannelAccessor.Channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); } catch (BackgroundJobExecutionException)