/// <summary>
        /// Creates a new instance of a configuration object that's
        /// copied from the stock configuration.
        ///
        /// Use this if you need to create multiple configurations
        /// for multiple Controllers running at the same time.
        /// </summary>
        /// <returns></returns>
        public static QueueMessageManagerConfiguration CreateConfiguration()
        {
            var manager = new QueueMessageManagerConfiguration();

            DataUtils.CopyObjectData(Current, manager);
            return(manager);
        }
        /// <summary>
        /// Initializes the QueueController from the 
        /// Queue Configuration Settings
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="queueManagerType"></param>
        public void Initialize(QueueMessageManagerConfiguration configuration = null, Type queueManagerType = null)
        {                        
            if (queueManagerType != null)
                QueueManagerType = queueManagerType;

            if (configuration == null)
                configuration = QueueMessageManagerConfiguration.Current;

            if (configuration == null)
                return;
                    
            ConnectionString = configuration.ConnectionString;
            ThreadCount = configuration.ControllerThreads;
            QueueName = configuration.QueueName ?? string.Empty;
            WaitInterval = configuration.WaitInterval;
        }
        /// <summary>
        /// Loads configuration settings from configuration file and loads up
        /// the Controllers list.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="managerType"></param>
        public void Initialize(QueueMessageManagerConfiguration configuration = null, Type managerType = null)
        {
            base.Initialize(configuration, managerType);

            // ignore controller list if controllers have been
            // explicitly set
            if (Controllers != null && Controllers.Count > 0)
            {
                return;
            }

            // load up the controllers
            Controllers = new List <QueueController>();

            if (configuration == null)
            {
                configuration = QueueMessageManagerConfiguration.Current;
            }
            if (managerType == null)
            {
                managerType = QueueManagerType ?? typeof(QueueMessageManagerSql);
            }

            if (configuration != null && configuration.Controllers != null)
            {
                // pass configuration to all the child controllers
                foreach (var config in configuration.Controllers)
                {
                    var ctrl = Activator.CreateInstance(GetType()) as QueueController;

                    ctrl.ConnectionString = string.IsNullOrEmpty(config.ConnectionString)
                        ? ConnectionString ?? ""
                        : config.ConnectionString;

                    ctrl.QueueName            = config.QueueName;
                    ctrl.ThreadCount          = config.ControllerThreads;
                    ctrl.WaitInterval         = config.WaitInterval;
                    ctrl.QueueManagerType     = managerType;
                    ctrl.OnCreateQueueManager = OnCreateQueueManager;

                    Controllers.Add(ctrl);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Initializes the QueueController from the
        /// Queue Configuration Settings
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="queueManagerType"></param>
        public void Initialize(QueueMessageManagerConfiguration configuration = null, Type queueManagerType = null)
        {
            if (queueManagerType != null)
            {
                QueueManagerType = queueManagerType;
            }

            if (configuration == null)
            {
                configuration = QueueMessageManagerConfiguration.Current;
            }

            if (configuration == null)
            {
                return;
            }

            ConnectionString = configuration.ConnectionString;
            ThreadCount      = configuration.ControllerThreads;
            QueueName        = configuration.QueueName ?? string.Empty;
            WaitInterval     = configuration.WaitInterval;
        }
        /// <summary>
        /// Loads configuration settings from configuration file and loads up
        /// the Controllers list.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="managerType"></param>
        public void Initialize(QueueMessageManagerConfiguration configuration = null, Type managerType = null)
        {            
            base.Initialize(configuration, managerType);

            // ignore controller list if controllers have been 
            // explicitly set
            if (Controllers != null && Controllers.Count > 0)
                return;

            // load up the controllers
            Controllers = new List<QueueController>();

            if (configuration == null)
                configuration = QueueMessageManagerConfiguration.Current;
            if (managerType == null)
                managerType = QueueManagerType ?? typeof(QueueMessageManagerSql);

            if (configuration != null && configuration.Controllers != null)
            {
                // pass configuration to all the child controllers
                foreach (var config in configuration.Controllers)
                {
                    var ctrl = Activator.CreateInstance(GetType()) as QueueController;

                    ctrl.ConnectionString = string.IsNullOrEmpty(config.ConnectionString)
                        ? ConnectionString ?? ""
                        : config.ConnectionString;

                    ctrl.QueueName = config.QueueName;
                    ctrl.ThreadCount = config.ControllerThreads;
                    ctrl.WaitInterval = config.WaitInterval;
                    ctrl.QueueManagerType = managerType;
                    ctrl.OnCreateQueueManager = OnCreateQueueManager;

                    Controllers.Add(ctrl);
                }
            }
        }
 static QueueMessageManagerConfiguration()
 {
     Current = new QueueMessageManagerConfiguration();
     Current.Initialize(sectionName: "QueueManagerConfiguration");
 }
 static QueueMessageManagerConfiguration()
 {
     Current = new QueueMessageManagerConfiguration();
     Current.Initialize(sectionName: "QueueManagerConfiguration");
 }
 /// <summary>
 /// Creates a new instance of a configuration object that's
 /// copied from the stock configuration.
 /// 
 /// Use this if you need to create multiple configurations
 /// for multiple Controllers running at the same time.
 /// </summary>
 /// <returns></returns>
 public static QueueMessageManagerConfiguration CreateConfiguration()
 {
     var manager = new QueueMessageManagerConfiguration();
     DataUtils.CopyObjectData(Current, manager);
     return manager;
 }