private void CreateScheduler() { lock (_startup) { if (_consumer != null) { return; } _container = new JobSchedulerContainer(container => container.Register(() => _timeFactory, LifeStyles.Singleton)); _scheduler = _container.CreateJobScheduler(); _scheduler.Start(); _consumerContainer = new SchedulerContainer(); _consumerScheduler = _consumerContainer.CreateTaskScheduler(); _taskFactory = _consumerContainer.CreateTaskFactory(_consumerScheduler); _taskFactory = _consumerContainer.CreateTaskFactory(_consumerScheduler); _taskFactory.Scheduler.Configuration.MaximumThreads = _configuration.ThreadsMax; _taskFactory.Scheduler.Configuration.MaxQueueSize = _configuration.QueueMax; _taskFactory.Scheduler.Configuration.WaitForThreadPoolToFinish = _configuration.WaitForThreadPoolToFinish; _taskFactory.Scheduler.Start(); _queueContainer = new QueueContainer <MemoryMessageQueueInit>(); _consumer = _queueContainer.CreateConsumerMethodQueueScheduler(QueueName, Connection, _taskFactory); _consumer.Start(); } }
private SchedulerTaskFactory Create(ATaskScheduler scheduler) { var fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); fixture.Inject(scheduler); var factory = fixture.Create<ITaskSchedulerFactory>(); factory.Create().Returns(scheduler); fixture.Inject(factory); return fixture.Create<SchedulerTaskFactory>(); }
private SchedulerTaskFactory Create(ATaskScheduler scheduler) { var fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); fixture.Inject(scheduler); var factory = fixture.Create <ITaskSchedulerFactory>(); factory.Create().Returns(scheduler); fixture.Inject(factory); return(fixture.Create <SchedulerTaskFactory>()); }
protected void CreateModuleIfNeeded(string queueName, ConsumerQueueTypes type = ConsumerQueueTypes.Poco, string workGroupName = null, int concurrencyLevel = 0, int maxQueueSize = 0) { if (_taskScheduler == null) { _taskScheduler = _schedulerContainer.Value.CreateTaskScheduler(); _taskFactory = _schedulerContainer.Value.CreateTaskFactory(_taskScheduler); } if (!string.IsNullOrWhiteSpace(queueName) && !Queues.ContainsKey(queueName)) { IConsumerBaseQueue queue = null; if (workGroupName != null) { if (!_taskScheduler.Started) { _taskScheduler.Start(); } var group = _taskScheduler.AddWorkGroup(workGroupName, concurrencyLevel, maxQueueSize); switch (type) { case ConsumerQueueTypes.Poco: queue = _queueContainer.Value.CreateConsumerQueueScheduler(queueName, ConfigurationManager.AppSettings["Connection"], _taskFactory, group); break; case ConsumerQueueTypes.Method: queue = _queueContainer.Value.CreateConsumerMethodQueueScheduler(queueName, ConfigurationManager.AppSettings["Connection"], _taskFactory, group); break; } } else { switch (type) { case ConsumerQueueTypes.Poco: queue = _queueContainer.Value.CreateConsumerQueueScheduler(queueName, ConfigurationManager.AppSettings["Connection"], _taskFactory); break; case ConsumerQueueTypes.Method: queue = _queueContainer.Value.CreateConsumerMethodQueueScheduler(queueName, ConfigurationManager.AppSettings["Connection"], _taskFactory); break; } } Queues.Add(queueName, queue); QueueStatus?.AddStatusProvider( QueueStatusContainer.Value.CreateStatusProvider <TTransportInit>(queueName, ConfigurationManager.AppSettings["Connection"])); } }
protected void CreateModuleIfNeeded(QueueConnection queueConnection, ConsumerQueueTypes type = ConsumerQueueTypes.Poco, string workGroupName = null, int concurrencyLevel = 0, int maxQueueSize = 0) { if (_taskScheduler == null) { _taskScheduler = _schedulerContainer.Value.CreateTaskScheduler(); _taskFactory = _schedulerContainer.Value.CreateTaskFactory(_taskScheduler); } if (!string.IsNullOrWhiteSpace(queueConnection.Queue) && !Queues.ContainsKey(queueConnection.Queue)) { IConsumerBaseQueue queue = null; if (workGroupName != null) { if (!_taskScheduler.Started) { _taskScheduler.Start(); } var group = _taskScheduler.AddWorkGroup(workGroupName, concurrencyLevel, maxQueueSize); switch (type) { case ConsumerQueueTypes.Poco: queue = _queueContainer.Value.CreateConsumerQueueScheduler(queueConnection, _taskFactory, group); break; case ConsumerQueueTypes.Method: queue = _queueContainer.Value.CreateConsumerMethodQueueScheduler(queueConnection, _taskFactory, group); break; } } else { switch (type) { case ConsumerQueueTypes.Poco: queue = _queueContainer.Value.CreateConsumerQueueScheduler(queueConnection, _taskFactory); break; case ConsumerQueueTypes.Method: queue = _queueContainer.Value.CreateConsumerMethodQueueScheduler(queueConnection, _taskFactory); break; } } Queues.Add(queueConnection.Queue, queue); } }