Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Volo.Abp.ExceptionHandling;
using Volo.Abp.RabbitMQ;
using Volo.Abp.Threading;
using Volo.Abp.Tracing;

namespace Volo.Abp.BackgroundJobs.RabbitMQ;

Expand All @@ -33,6 +34,7 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
protected IBackgroundJobExecuter JobExecuter { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
protected IExceptionNotifier ExceptionNotifier { get; }
protected ICorrelationIdProvider CorrelationIdProvider { get; }

protected SemaphoreSlim SyncObj = new SemaphoreSlim(1, 1);
protected bool IsDiposed { get; private set; }
Expand All @@ -44,14 +46,16 @@ public JobQueue(
IRabbitMqSerializer serializer,
IBackgroundJobExecuter jobExecuter,
IServiceScopeFactory serviceScopeFactory,
IExceptionNotifier exceptionNotifier)
IExceptionNotifier exceptionNotifier,
ICorrelationIdProvider correlationIdProvider)
{
AbpBackgroundJobOptions = backgroundJobOptions.Value;
AbpRabbitMqBackgroundJobOptions = rabbitMqAbpBackgroundJobOptions.Value;
Serializer = serializer;
JobExecuter = jobExecuter;
ServiceScopeFactory = serviceScopeFactory;
ExceptionNotifier = exceptionNotifier;
CorrelationIdProvider = correlationIdProvider;
ChannelPool = channelPool;

JobConfiguration = AbpBackgroundJobOptions.GetJob(typeof(TArgs));
Expand Down Expand Up @@ -201,7 +205,10 @@ protected virtual async Task MessageReceived(object sender, BasicDeliverEventArg

try
{
await JobExecuter.ExecuteAsync(context);
using (CorrelationIdProvider.Change(ea.BasicProperties.CorrelationId))
{
await JobExecuter.ExecuteAsync(context);
}
await ChannelAccessor!.Channel.BasicAckAsync(deliveryTag: ea.DeliveryTag, multiple: false);
}
catch (BackgroundJobExecutionException)
Expand Down
Loading