Merge pull request #6413 from abpframework/maliming/JobQueue

Use AsyncEventingBasicConsumer for RabbitMQ's JobQueue.
pull/6455/head
liangshiwei 5 years ago committed by GitHub
commit f24f164a3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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<JobQueue<TArgs>> 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)

Loading…
Cancel
Save