public MessagePump(
            ReceiveSettings settings,
            ConnectionFactory connectionFactory,
            IRoutingTopology routingTopology,
            MessageConverter messageConverter,
            string consumerTag,
            ChannelProvider channelProvider,
            TimeSpan timeToWaitBeforeTriggeringCircuitBreaker,
            PrefetchCountCalculation prefetchCountCalculation,
            Action <string, Exception,
                    CancellationToken> criticalErrorAction,
            TimeSpan retryDelay)
        {
            this.settings          = settings;
            this.connectionFactory = connectionFactory;
            this.messageConverter  = messageConverter;
            this.consumerTag       = consumerTag;
            this.channelProvider   = channelProvider;
            this.timeToWaitBeforeTriggeringCircuitBreaker = timeToWaitBeforeTriggeringCircuitBreaker;
            this.prefetchCountCalculation = prefetchCountCalculation;
            this.criticalErrorAction      = criticalErrorAction;
            this.retryDelay = retryDelay;

            ReceiveAddress = RabbitMQTransportInfrastructure.TranslateAddress(settings.ReceiveAddress);

            if (settings.UsePublishSubscribe)
            {
                Subscriptions = new SubscriptionManager(connectionFactory, routingTopology, ReceiveAddress);
            }

            queuePurger = new QueuePurger(connectionFactory);

            name = $"{ReceiveAddress} MessagePump";
        }
예제 #2
0
 public MessagePump(ConnectionFactory connectionFactory, MessageConverter messageConverter, string consumerTag, IChannelProvider channelProvider, QueuePurger queuePurger, TimeSpan timeToWaitBeforeTriggeringCircuitBreaker, int prefetchMultiplier, ushort overriddenPrefetchCount)
 {
     this.connectionFactory = connectionFactory;
     this.messageConverter  = messageConverter;
     this.consumerTag       = consumerTag;
     this.channelProvider   = channelProvider;
     this.queuePurger       = queuePurger;
     this.timeToWaitBeforeTriggeringCircuitBreaker = timeToWaitBeforeTriggeringCircuitBreaker;
     this.prefetchMultiplier      = prefetchMultiplier;
     this.overriddenPrefetchCount = overriddenPrefetchCount;
 }
        IPushMessages CreateMessagePump()
        {
            MessageConverter messageConverter;

            if (settings.HasSetting(SettingsKeys.CustomMessageIdStrategy))
            {
                messageConverter = new MessageConverter(settings.Get <Func <BasicDeliverEventArgs, string> >(SettingsKeys.CustomMessageIdStrategy));
            }
            else
            {
                messageConverter = new MessageConverter();
            }

            string hostDisplayName;

            if (!settings.TryGet("NServiceBus.HostInformation.DisplayName", out hostDisplayName))
            {
                hostDisplayName = Support.RuntimeEnvironment.MachineName;
            }

            var consumerTag = $"{hostDisplayName} - {settings.EndpointName()}";

            var queuePurger = new QueuePurger(connectionFactory);

            TimeSpan timeToWaitBeforeTriggeringCircuitBreaker;

            if (!settings.TryGet(SettingsKeys.TimeToWaitBeforeTriggeringCircuitBreaker, out timeToWaitBeforeTriggeringCircuitBreaker))
            {
                timeToWaitBeforeTriggeringCircuitBreaker = TimeSpan.FromMinutes(2);
            }

            int prefetchMultiplier;

            if (!settings.TryGet(SettingsKeys.PrefetchMultiplier, out prefetchMultiplier))
            {
                prefetchMultiplier = 3;
            }

            ushort prefetchCount;

            if (!settings.TryGet(SettingsKeys.PrefetchCount, out prefetchCount))
            {
                prefetchCount = 0;
            }

            return(new MessagePump(connectionFactory, messageConverter, consumerTag, channelProvider, queuePurger, timeToWaitBeforeTriggeringCircuitBreaker, prefetchMultiplier, prefetchCount));
        }
예제 #4
0
        public MessagePump(ConnectionFactory connectionFactory, IRoutingTopology routingTopology, MessageConverter messageConverter, string consumerTag,
                           ChannelProvider channelProvider, TimeSpan timeToWaitBeforeTriggeringCircuitBreaker,
                           PrefetchCountCalculation prefetchCountCalculation, ReceiveSettings settings,
                           Action <string, Exception, CancellationToken> criticalErrorAction)
        {
            this.connectionFactory = connectionFactory;
            this.messageConverter  = messageConverter;
            this.consumerTag       = consumerTag;
            this.channelProvider   = channelProvider;
            this.timeToWaitBeforeTriggeringCircuitBreaker = timeToWaitBeforeTriggeringCircuitBreaker;
            this.prefetchCountCalculation = prefetchCountCalculation;
            this.settings            = settings;
            this.criticalErrorAction = criticalErrorAction;

            if (settings.UsePublishSubscribe)
            {
                Subscriptions = new SubscriptionManager(connectionFactory, routingTopology, settings.ReceiveAddress);
            }

            queuePurger = new QueuePurger(connectionFactory);
        }