/// <summary> /// Creates the worker factory /// </summary> public ThreadPoolWorkerFactory(ITransport transport, IRebusLoggerFactory rebusLoggerFactory, IPipeline pipeline, IPipelineInvoker pipelineInvoker, Options options, Func<RebusBus> busGetter, BusLifetimeEvents busLifetimeEvents, ISyncBackoffStrategy backoffStrategy) { if (transport == null) throw new ArgumentNullException(nameof(transport)); if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory)); if (pipeline == null) throw new ArgumentNullException(nameof(pipeline)); if (pipelineInvoker == null) throw new ArgumentNullException(nameof(pipelineInvoker)); if (options == null) throw new ArgumentNullException(nameof(options)); if (busGetter == null) throw new ArgumentNullException(nameof(busGetter)); if (busLifetimeEvents == null) throw new ArgumentNullException(nameof(busLifetimeEvents)); if (backoffStrategy == null) throw new ArgumentNullException(nameof(backoffStrategy)); _transport = transport; _rebusLoggerFactory = rebusLoggerFactory; _pipeline = pipeline; _pipelineInvoker = pipelineInvoker; _options = options; _busGetter = busGetter; _backoffStrategy = backoffStrategy; _parallelOperationsManager = new ParallelOperationsManager(options.MaxParallelism); _log = _rebusLoggerFactory.GetCurrentClassLogger(); if (_options.MaxParallelism < 1) { throw new ArgumentException($"Max parallelism is {_options.MaxParallelism} which is an invalid value"); } if (options.WorkerShutdownTimeout < TimeSpan.Zero) { throw new ArgumentOutOfRangeException($"Cannot use '{options.WorkerShutdownTimeout}' as worker shutdown timeout as it"); } busLifetimeEvents.WorkersStopped += WaitForContinuationsToFinish; }
/// <summary> /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages /// and the specified <see cref="ITransport"/> to deliver messages when they're due. /// </summary> public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory) { _timeoutManager = timeoutManager; _transport = transport; _options = options; _log = rebusLoggerFactory.GetCurrentClassLogger(); _dueMessagesSenderBackgroundTask = asyncTaskFactory.Create(DueMessagesSenderTaskName, TimerElapsed, intervalSeconds: 1); }
/// <summary> /// Constructs the bus. /// </summary> public RebusBus(IWorkerFactory workerFactory, IRouter router, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ISubscriptionStorage subscriptionStorage, Options options) { _workerFactory = workerFactory; _router = router; _transport = transport; _pipeline = pipeline; _pipelineInvoker = pipelineInvoker; _subscriptionStorage = subscriptionStorage; _options = options; }
/// <summary> /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages /// and the specified <see cref="ITransport"/> to deliver messages when they're due. /// </summary> public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options) { _timeoutManager = timeoutManager; _transport = transport; _options = options; _dueMessagesSenderBackgroundTask = new AsyncTask(DueMessagesSenderTaskName, TimerElapsed) { Interval = TimeSpan.FromSeconds(1) }; }
/// <summary> /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages /// and the specified <see cref="ITransport"/> to deliver messages when they're due. /// </summary> public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory) { _timeoutManager = timeoutManager; _transport = transport; _options = options; _log = rebusLoggerFactory.GetCurrentClassLogger(); _dueMessagesSenderBackgroundTask = new AsyncTask(DueMessagesSenderTaskName, TimerElapsed, rebusLoggerFactory) { Interval = TimeSpan.FromSeconds(1) }; }
internal ThreadPoolWorker(string name, ITransport transport, IRebusLoggerFactory rebusLoggerFactory, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ParallelOperationsManager parallelOperationsManager, RebusBus owningBus, Options options, ISyncBackoffStrategy backoffStrategy) { Name = name; _log = rebusLoggerFactory.GetCurrentClassLogger(); _transport = transport; _pipeline = pipeline; _pipelineInvoker = pipelineInvoker; _parallelOperationsManager = parallelOperationsManager; _owningBus = owningBus; _options = options; _backoffStrategy = backoffStrategy; _workerThread = new Thread(Run) { Name = name, IsBackground = true }; _workerThread.Start(); }
/// <summary> /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages /// and the specified <see cref="ITransport"/> to deliver messages when they're due. /// </summary> public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory) { if (timeoutManager == null) throw new ArgumentNullException(nameof(timeoutManager)); if (transport == null) throw new ArgumentNullException(nameof(transport)); if (options == null) throw new ArgumentNullException(nameof(options)); if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory)); if (asyncTaskFactory == null) throw new ArgumentNullException(nameof(asyncTaskFactory)); _timeoutManager = timeoutManager; _transport = transport; _options = options; _log = rebusLoggerFactory.GetCurrentClassLogger(); var dueTimeoutsPollIntervalSeconds = (int)options.DueTimeoutsPollInterval.TotalSeconds; var intervalToUse = dueTimeoutsPollIntervalSeconds >= 1 ? dueTimeoutsPollIntervalSeconds : 1; _dueMessagesSenderBackgroundTask = asyncTaskFactory.Create(DueMessagesSenderTaskName, TimerElapsed, intervalSeconds: intervalToUse); }