/// <inheritdoc /> public Task HandleAsync <T>(IWorkGroup workGroup, IReceivedMessage <T> message, IWorkerNotification notifications, Action <IReceivedMessage <T>, IWorkerNotification> functionToRun, ITaskFactory taskFactory) where T : class { using (var scope = _tracer.StartActivity("SchedulerMessageHandler")) { return(_handler.HandleAsync(workGroup, message, notifications, functionToRun, taskFactory)); } }
/// <summary> /// Starts the queue /// </summary> /// <typeparam name="T"></typeparam> /// <param name="functionToRun">The function to run to handle messages.</param> public void Start <T>(Action <IReceivedMessage <T>, IWorkerNotification> functionToRun) where T : class { ThrowIfDisposed(); Guard.NotNull(() => functionToRun, functionToRun); if (_taskFactory.Value.Scheduler == null) { throw new DotNetWorkQueueException("A scheduler must be created before starting the queue"); } if (!_taskFactory.Value.Scheduler.Started) { throw new DotNetWorkQueueException("The scheduler must be started before starting the queue"); } //let the scheduler know it has another client if (!_schedulerId.HasValue) { _schedulerId = _taskFactory.Value.Scheduler.Subscribe(); } _queue.Start <T>( (message, notifications) => _schedulerMessageHandler.HandleAsync(WorkGroup, message, notifications, functionToRun, _taskFactory.Value)); }
/// <inheritdoc /> public Task HandleAsync <T>(IWorkGroup workGroup, IReceivedMessage <T> message, IWorkerNotification notifications, Action <IReceivedMessage <T>, IWorkerNotification> functionToRun, ITaskFactory taskFactory) where T : class { using (IScope scope = _tracer.BuildSpan("SchedulerMessageHandler").StartActive(finishSpanOnDispose: true)) { return(_handler.HandleAsync(workGroup, message, notifications, functionToRun, taskFactory)); } }