Esempio n. 1
0
        /// <summary>
        /// Init the module with provided <see cref="LogicalPriorityMapper"/>
        /// </summary>
        /// <param name="mapper"></param>
        /// <param name="routeFinder">custom route finder</param>
        /// <returns></returns>
        public RabbitMqModule Load(LogicalPriorityMapper mapper, IRouteFinder routeFinder = null)
        {
            var internalBus = InternalBus.Current;
            var logger = DependencyResolver.Current.GetService<ILogger>() ?? new NullLogger();
            _rabbitBus = new RabbitMqBus(logger, internalBus, mapper, MessageQueueConnectionString, Environment, SetupQueues);
            if (routeFinder != null)
            {
                _rabbitBus.SetRouteFinder(routeFinder);
            }
            InternalBus.Current = new RabbitMqBusAdapter(_rabbitBus);

            Global.PendingJobCount = _rabbitBus.GetMessageCount;
            Burrow.Global.DefaultConsumerBatchSize = ushort.Parse(ConfigurationManager.AppSettings["TaskConcurrencyLevel"] ?? "4");
            Burrow.Global.PreFetchSize = uint.Parse(ConfigurationManager.AppSettings["PreFetchSize"] ?? ((Burrow.Global.DefaultConsumerBatchSize) * 2).ToString(CultureInfo.InvariantCulture));
            return this;
        }