Fixing that a JobsQueue job re-queuing itself caused a DB deadlock.

JobsQueueProcessor is a singleton, so every IDependency it gets injected should be wrapped into Work<T>.
This commit is contained in:
Lombiq
2015-06-09 14:13:01 +02:00
parent 31a325a810
commit 8a7a300414

View File

@@ -15,14 +15,14 @@ namespace Orchard.JobsQueue.Services {
private readonly Work<IJobsQueueManager> _jobsQueueManager; private readonly Work<IJobsQueueManager> _jobsQueueManager;
private readonly Work<IClock> _clock; private readonly Work<IClock> _clock;
private readonly Work<ITaskLeaseService> _taskLeaseService; private readonly Work<ITaskLeaseService> _taskLeaseService;
private readonly IEventBus _eventBus; private readonly Work<IEventBus> _eventBus;
private readonly ReaderWriterLockSlim _rwl = new ReaderWriterLockSlim(); private readonly ReaderWriterLockSlim _rwl = new ReaderWriterLockSlim();
public JobsQueueProcessor( public JobsQueueProcessor(
Work<IClock> clock, Work<IClock> clock,
Work<IJobsQueueManager> jobsQueueManager, Work<IJobsQueueManager> jobsQueueManager,
Work<ITaskLeaseService> taskLeaseService, Work<ITaskLeaseService> taskLeaseService,
IEventBus eventBus) { Work<IEventBus> eventBus) {
_clock = clock; _clock = clock;
_jobsQueueManager = jobsQueueManager; _jobsQueueManager = jobsQueueManager;
_taskLeaseService = taskLeaseService; _taskLeaseService = taskLeaseService;
@@ -59,7 +59,7 @@ namespace Orchard.JobsQueue.Services {
var payload = JObject.Parse(job.Parameters); var payload = JObject.Parse(job.Parameters);
var parameters = payload.ToDictionary(); var parameters = payload.ToDictionary();
_eventBus.Notify(job.Message, parameters); _eventBus.Value.Notify(job.Message, parameters);
Logger.Debug("Processed job Id {0}.", job.Id); Logger.Debug("Processed job Id {0}.", job.Id);
} }