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); } }