Exemplo n.º 1
0
        public DelayedDeliveryPump(MsmqMessageDispatcher dispatcher,
                                   DueDelayedMessagePoller poller,
                                   IDelayedMessageStore storage,
                                   MessagePump messagePump,
                                   string errorQueue,
                                   int numberOfRetries,
                                   Action <string, Exception, CancellationToken> criticalErrorAction,
                                   TimeSpan timeToWaitForStoreCircuitBreaker,
                                   Dictionary <string, string> faultMetadata,
                                   TransportTransactionMode transportTransactionMode)
        {
            this.dispatcher      = dispatcher;
            this.poller          = poller;
            this.storage         = storage;
            this.numberOfRetries = numberOfRetries;
            this.faultMetadata   = faultMetadata;
            pump            = messagePump;
            this.errorQueue = errorQueue;

            txOption = transportTransactionMode == TransportTransactionMode.TransactionScope
                ? TransactionScopeOption.Required
                : TransactionScopeOption.RequiresNew;

            storeCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("DelayedDeliveryStore", timeToWaitForStoreCircuitBreaker,
                                                                             ex => criticalErrorAction("Failed to store delayed message", ex, CancellationToken.None));
        }
        public DueDelayedMessagePoller(MsmqMessageDispatcher dispatcher,
                                       IDelayedMessageStore delayedMessageStore,
                                       int numberOfRetries,
                                       Action <string, Exception, CancellationToken> criticalErrorAction,
                                       string timeoutsErrorQueue,
                                       Dictionary <string, string> faultMetadata,
                                       TransportTransactionMode transportTransactionMode,
                                       TimeSpan timeToTriggerFetchCircuitBreaker,
                                       TimeSpan timeToTriggerDispatchCircuitBreaker,
                                       int maximumRecoveryFailuresPerSecond,
                                       string timeoutsQueueTransportAddress)
        {
            txOption = transportTransactionMode == TransportTransactionMode.TransactionScope
                ? TransactionScopeOption.Required
                : TransactionScopeOption.RequiresNew;
            this.delayedMessageStore = delayedMessageStore;
            errorQueue         = timeoutsErrorQueue;
            this.faultMetadata = faultMetadata;
            this.timeoutsQueueTransportAddress = timeoutsQueueTransportAddress;
            this.numberOfRetries = numberOfRetries;
            this.dispatcher      = dispatcher;
            fetchCircuitBreaker  = new RepeatedFailuresOverTimeCircuitBreaker("MsmqDelayedMessageFetch", timeToTriggerFetchCircuitBreaker,
                                                                              ex => criticalErrorAction("Failed to fetch due delayed messages from the storage", ex, tokenSource?.Token ?? CancellationToken.None));

            dispatchCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("MsmqDelayedMessageDispatch", timeToTriggerDispatchCircuitBreaker,
                                                                                ex => criticalErrorAction("Failed to dispatch delayed messages to destination", ex, tokenSource?.Token ?? CancellationToken.None));

            failureHandlingCircuitBreaker = new FailureRateCircuitBreaker("MsmqDelayedMessageFailureHandling", maximumRecoveryFailuresPerSecond,
                                                                          ex => criticalErrorAction("Failed to execute error handling for delayed message forwarding", ex, tokenSource?.Token ?? CancellationToken.None));

            signalQueue = Channel.CreateBounded <bool>(1);
            taskQueue   = Channel.CreateBounded <Task>(2);
        }
 protected AdaptiveExecutor(string name, RepeatedFailuresOverTimeCircuitBreaker circuitBreaker, TransportNotifications transportNotifications, TimeSpan slowTaskThreshold)
 {
     this.name                   = name;
     this.circuitBreaker         = circuitBreaker;
     this.transportNotifications = transportNotifications;
     this.slowTaskThreshold      = slowTaskThreshold;
 }
Exemplo n.º 4
0
 public void Start()
 {
     tokenSource    = new CancellationTokenSource();
     circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("EventDispatcher",
                                                                 TimeSpan.FromMinutes(2),
                                                                 ex => Configure.Instance.RaiseCriticalError("Repeated failures when dispatching external integration events.", ex),
                                                                 TimeSpan.FromSeconds(20));
     StartDispatcher();
 }
Exemplo n.º 5
0
 public void Start()
 {
     tokenSource = new CancellationTokenSource();
     circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("EventDispatcher",
         TimeSpan.FromMinutes(2),
         ex => Configure.Instance.RaiseCriticalError("Repeated failures when dispatching external integration events.", ex),
         TimeSpan.FromSeconds(20));
     StartDispatcher();
 }
Exemplo n.º 6
0
        protected override void OnStart()
        {
            subscription = store.Changes().ForDocumentsStartingWith("ExternalIntegrationDispatchRequests").Where(c => c.Type == DocumentChangeTypes.Put).Subscribe(OnNext);

            tokenSource    = new CancellationTokenSource();
            circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("EventDispatcher",
                                                                        TimeSpan.FromMinutes(5),
                                                                        ex => criticalError.Raise("Repeated failures when dispatching external integration events.", ex),
                                                                        TimeSpan.FromSeconds(20));

            StartDispatcher();
        }
        protected override Task OnStart(IMessageSession busSession)
        {
            var configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/TimeToKeepDeduplicationData");

            if (configValue == null)
            {
                timeToKeepDeduplicationData = TimeSpan.FromDays(7);
            }
            else if (!TimeSpan.TryParse(configValue, out timeToKeepDeduplicationData))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/TimeToKeepDeduplicationData\" AppSetting. Please ensure it is a TimeSpan.");
            }

            configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/FrequencyToRunDeduplicationDataCleanup");

            if (configValue == null)
            {
                frequencyToRunDeduplicationDataCleanup = DefaultFrequencyToRunDeduplicationDataCleanup;
            }
            else if (!TimeSpan.TryParse(configValue, out frequencyToRunDeduplicationDataCleanup))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/FrequencyToRunDeduplicationDataCleanup\" AppSetting. Please ensure it is a TimeSpan.");
            }

            configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/TimeToWaitBeforeTriggeringCriticalErrorWhenCleanupTaskFails");

            if (configValue == null)
            {
                timeToWaitBeforeTriggeringCriticalError = DefaultTimeToWaitBeforeTriggeringCriticalError;
            }
            else if (!TimeSpan.TryParse(configValue, out timeToWaitBeforeTriggeringCriticalError))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/TimeToWaitBeforeTriggeringCriticalErrorWhenCleanupTaskFails\" AppSetting. Please ensure it is a TimeSpan.");
            }

            circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker(
                "OutboxCleanupTaskConnectivity",
                timeToWaitBeforeTriggeringCriticalError,
                ex => criticalError.Raise("Failed to clean the Outbox.", ex)
                );

            if (Timeout.InfiniteTimeSpan == frequencyToRunDeduplicationDataCleanup)
            {
                Logger.InfoFormat("Outbox cleanup task is disabled.");
            }

            cancellationTokenSource = new CancellationTokenSource();

            cleanup = Task.Run(() => PerformCleanup(cancellationTokenSource.Token), CancellationToken.None);

            return(Task.CompletedTask);
        }
 public AdaptivePollingReceiver(
     IReceiveStrategy receiveStrategy,
     TableBasedQueue queue,
     Action <TransportMessage, Exception> endProcessMessage,
     RepeatedFailuresOverTimeCircuitBreaker circuitBreaker,
     TransportNotifications transportNotifications)
     : base(queue.ToString(), circuitBreaker, transportNotifications, TimeSpan.FromMilliseconds(SlowTaskThresholdInMilliseconds))
 {
     this.receiveStrategy        = receiveStrategy;
     this.queue                  = queue;
     this.endProcessMessage      = endProcessMessage;
     this.transportNotifications = transportNotifications;
 }
Exemplo n.º 9
0
 public AdaptivePollingReceiver(
     IReceiveStrategy receiveStrategy,
     TableBasedQueue queue,
     Action <TransportMessage, Exception> endProcessMessage,
     RepeatedFailuresOverTimeCircuitBreaker circuitBreaker,
     TransportNotifications transportNotifications)
     : base(circuitBreaker)
 {
     this.receiveStrategy        = receiveStrategy;
     this.queue                  = queue;
     this.endProcessMessage      = endProcessMessage;
     this.transportNotifications = transportNotifications;
 }
Exemplo n.º 10
0
        public void Start()
        {
            circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("TimeoutStorageConnectivity", TimeSpan.FromMinutes(2),
                                                                        ex =>
                                                                        CriticalError.Raise("Repeated failures when fetching timeouts from storage, endpoint will be terminated.", ex));

            TimeoutManager.TimeoutPushed = TimeoutsManagerOnTimeoutPushed;

            SecondsToSleepBetweenPolls = 1;

            tokenSource = new CancellationTokenSource();

            StartPoller();
        }
Exemplo n.º 11
0
        public void Start()
        {
            circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("TimeoutStorageConnectivity", TimeToWaitBeforeTriggeringCriticalError,
                ex =>
                    CriticalError.Raise("Repeated failures when fetching timeouts from storage, endpoint will be terminated.", ex));

            TimeoutManager.TimeoutPushed = TimeoutsManagerOnTimeoutPushed;

            SecondsToSleepBetweenPolls = 1;

            tokenSource = new CancellationTokenSource();

            StartPoller();
        }
 public SqlServerPollingDequeueStrategy(
     LocalConnectionParams locaConnectionParams,
     ReceiveStrategyFactory receiveStrategyFactory,
     IQueuePurger queuePurger,
     SecondaryReceiveConfiguration secondaryReceiveConfiguration,
     TransportNotifications transportNotifications,
     RepeatedFailuresOverTimeCircuitBreaker circuitBreaker)
 {
     this.locaConnectionParams          = locaConnectionParams;
     this.receiveStrategyFactory        = receiveStrategyFactory;
     this.queuePurger                   = queuePurger;
     this.secondaryReceiveConfiguration = secondaryReceiveConfiguration;
     this.transportNotifications        = transportNotifications;
     this.circuitBreaker                = circuitBreaker;
 }
 public SqlServerPollingDequeueStrategy(
     LocalConnectionParams locaConnectionParams,
     ReceiveStrategyFactory receiveStrategyFactory, 
     IQueuePurger queuePurger, 
     SecondaryReceiveConfiguration secondaryReceiveConfiguration,
     TransportNotifications transportNotifications, 
     RepeatedFailuresOverTimeCircuitBreaker circuitBreaker)
 {
     this.locaConnectionParams = locaConnectionParams;
     this.receiveStrategyFactory = receiveStrategyFactory;
     this.queuePurger = queuePurger;
     this.secondaryReceiveConfiguration = secondaryReceiveConfiguration;
     this.transportNotifications = transportNotifications;
     this.circuitBreaker = circuitBreaker;
 }
        public ServiceControlBackend(IDispatchMessages messageSender, ReadOnlySettings settings, CriticalError criticalError)
        {
            this.settings = settings;
            this.messageSender = messageSender;
            serializer = new DataContractJsonSerializer(typeof(ReportCustomCheckResult), new DataContractJsonSerializerSettings
            {
                DateTimeFormat = new DateTimeFormat("o"),
                EmitTypeInformation = EmitTypeInformation.Always,
            });

            serviceControlBackendAddress = GetServiceControlAddress();

            circuitBreaker =
                new RepeatedFailuresOverTimeCircuitBreaker("ServiceControlConnectivity", TimeSpan.FromMinutes(2),
                    ex =>
                        criticalError.Raise("You have ServiceControl plugins installed in your endpoint, however, this endpoint is repeatedly unable to contact the ServiceControl backend to report endpoint information.", ex));
        }
Exemplo n.º 15
0
        static void SetupTimeoutPoller(FeatureConfigurationContext context, string dispatcherAddress)
        {
            context.Container.ConfigureComponent(b =>
            {
                var waitTime = context.Settings.Get<TimeSpan>("TimeToWaitBeforeTriggeringCriticalErrorForTimeoutPersisterReceiver");

                var criticalError = b.Build<CriticalError>();

                var circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("TimeoutStorageConnectivity",
                    waitTime,
                    ex => criticalError.Raise("Repeated failures when fetching timeouts from storage, endpoint will be terminated.", ex));

                return new ExpiredTimeoutsPoller(b.Build<IQueryTimeouts>(), b.Build<IDispatchMessages>(), dispatcherAddress, circuitBreaker, () => DateTime.UtcNow);
            }, DependencyLifecycle.SingleInstance);

            context.RegisterStartupTask(b => new TimeoutPollerRunner(b.Build<ExpiredTimeoutsPoller>()));
        }
        public ServiceControlBackend(IDispatchMessages messageSender, ReadOnlySettings settings, CriticalError criticalError)
        {
            this.settings      = settings;
            this.messageSender = messageSender;
            serializer         = new DataContractJsonSerializer(typeof(ReportCustomCheckResult), new DataContractJsonSerializerSettings
            {
                DateTimeFormat      = new DateTimeFormat("o"),
                EmitTypeInformation = EmitTypeInformation.Always,
            });

            serviceControlBackendAddress = GetServiceControlAddress();

            circuitBreaker =
                new RepeatedFailuresOverTimeCircuitBreaker("ServiceControlConnectivity", TimeSpan.FromMinutes(2),
                                                           ex =>
                                                           criticalError.Raise("You have ServiceControl plugins installed in your endpoint, however, this endpoint is repeatedly unable to contact the ServiceControl backend to report endpoint information.", ex));
        }
Exemplo n.º 17
0
        static void SetupTimeoutPoller(FeatureConfigurationContext context, string dispatcherAddress)
        {
            context.Container.ConfigureComponent(b =>
            {
                var waitTime = context.Settings.Get <TimeSpan>("TimeToWaitBeforeTriggeringCriticalErrorForTimeoutPersisterReceiver");

                var criticalError = b.GetRequiredService <CriticalError>();

                var circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("TimeoutStorageConnectivity",
                                                                                waitTime,
                                                                                ex => criticalError.Raise("Repeated failures when fetching timeouts from storage, endpoint will be terminated.", ex));

                return(new ExpiredTimeoutsPoller(b.GetRequiredService <IQueryTimeouts>(), b.GetRequiredService <IDispatchMessages>(), dispatcherAddress, circuitBreaker, () => DateTime.UtcNow));
            }, DependencyLifecycle.SingleInstance);

            context.RegisterStartupTask(b => new TimeoutPollerRunner(b.GetRequiredService <ExpiredTimeoutsPoller>()));
        }
Exemplo n.º 18
0
        protected override Task OnStart(IMessageSession busSession)
        {
            var configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/TimeToKeepDeduplicationData");

            if (configValue == null)
            {
                timeToKeepDeduplicationData = TimeSpan.FromDays(7);
            }
            else if (!TimeSpan.TryParse(configValue, out timeToKeepDeduplicationData))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/TimeToKeepDeduplicationData\" AppSetting. Please ensure it is a TimeSpan.");
            }

            configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/FrequencyToRunDeduplicationDataCleanup");

            if (configValue == null)
            {
                frequencyToRunDeduplicationDataCleanup = DefaultFrequencyToRunDeduplicationDataCleanup;
            }
            else if (!TimeSpan.TryParse(configValue, out frequencyToRunDeduplicationDataCleanup))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/FrequencyToRunDeduplicationDataCleanup\" AppSetting. Please ensure it is a TimeSpan.");
            }

            configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox/NHibernate/TimeToWaitBeforeTriggeringCriticalErrorWhenCleanupTaskFails");

            if (configValue == null)
            {
                timeToWaitBeforeTriggeringCriticalError = DefaultTimeToWaitBeforeTriggeringCriticalError;
            }
            else if (!TimeSpan.TryParse(configValue, out timeToWaitBeforeTriggeringCriticalError))
            {
                throw new Exception("Invalid value in \"NServiceBus/Outbox/NHibernate/TimeToWaitBeforeTriggeringCriticalErrorWhenCleanupTaskFails\" AppSetting. Please ensure it is a TimeSpan.");
            }

            circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker(
                "OutboxCleanupTaskConnectivity",
                timeToWaitBeforeTriggeringCriticalError,
                ex => criticalError.Raise("Failed to clean the Oubox.", ex)
                );

            cleanupTimer = new Timer(PerformCleanup, null, OutboxCleanupStartupDelay, frequencyToRunDeduplicationDataCleanup);

            return(Task.FromResult(true));
        }
        public  ServiceControlBackend(ISendMessages messageSender, Configure configure, CriticalError criticalError)
        {
            this.configure = configure;
            this.criticalError = criticalError;
            this.messageSender = messageSender;
            serializer = new JsonMessageSerializer(new SimpleMessageMapper());

            serviceControlBackendAddress = GetServiceControlAddress();
            VerifyIfServiceControlQueueExists();

            circuitBreaker =
            new RepeatedFailuresOverTimeCircuitBreaker("ServiceControlConnectivity", TimeSpan.FromMinutes(2),
                ex =>
                    criticalError.Raise(
                        "This endpoint is repeatedly unable to contact the ServiceControl backend to report endpoint information. You have the ServiceControl plugins installed in your endpoint. However, please ensure that the Particular ServiceControl service is installed on this machine, " +
                                   "or if running ServiceControl on a different machine, then ensure that your endpoint's app.config / web.config, AppSettings has the following key set appropriately: ServiceControl/Queue. \r\n" +
                                   @"For example: <add key=""ServiceControl/Queue"" value=""particular.servicecontrol@machine""/>" +
                                   "\r\n", ex));
        }
        public ServiceControlBackend(ISendMessages messageSender, Configure configure, CriticalError criticalError)
        {
            this.configure     = configure;
            this.criticalError = criticalError;
            this.messageSender = messageSender;
            serializer         = new JsonMessageSerializer(new SimpleMessageMapper());

            serviceControlBackendAddress = GetServiceControlAddress();
            VerifyIfServiceControlQueueExists();

            circuitBreaker =
                new RepeatedFailuresOverTimeCircuitBreaker("ServiceControlConnectivity", TimeSpan.FromMinutes(2),
                                                           ex =>
                                                           criticalError.Raise(
                                                               "This endpoint is repeatedly unable to contact the ServiceControl backend to report endpoint information. You have the ServiceControl plugins installed in your endpoint. However, please ensure that the Particular ServiceControl service is installed on this machine, " +
                                                               "or if running ServiceControl on a different machine, then ensure that your endpoint's app.config / web.config, AppSettings has the following key set appropriately: ServiceControl/Queue. \r\n" +
                                                               @"For example: <add key=""ServiceControl/Queue"" value=""particular.servicecontrol@machine""/>" +
                                                               "\r\n", ex));
        }
 protected AdaptiveExecutor(RepeatedFailuresOverTimeCircuitBreaker circuitBreaker)
 {
     this.circuitBreaker = circuitBreaker;
 }
Exemplo n.º 22
0
 public KafkaDequeueStrategy(IManageKafkaConnections connectionManager, RepeatedFailuresOverTimeCircuitBreaker circuitBreaker, ReceiveOptions receiveOptions)
 {
     this.connectionManager = connectionManager;
     this.circuitBreaker    = circuitBreaker;
     this.receiveOptions    = receiveOptions;
 }
Exemplo n.º 23
0
 public RawAzureServiceBusDequeueStrategy(ITopology topology, CriticalError criticalError)
 {
     this.topology      = topology;
     this.criticalError = criticalError;
     circuitBreaker     = new RepeatedFailuresOverTimeCircuitBreaker("AzureServiceBusDequeueStrategy", TimeSpan.FromSeconds(30), ex => criticalError.Raise(string.Format("Failed to receive message from Azure ServiceBus."), ex));
 }
 public AzureServiceBusDequeueStrategy(ITopology topology, CriticalError criticalError)
 {
     this.topology = topology;
     this.criticalError = criticalError;
     circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("AzureServiceBusDequeueStrategy", TimeSpan.FromSeconds(30), ex => criticalError.Raise("Failed to receive message from Azure ServiceBus.", ex));
 }
 public KafkaDequeueStrategy(IManageKafkaConnections connectionManager, RepeatedFailuresOverTimeCircuitBreaker circuitBreaker, ReceiveOptions receiveOptions)
 {
     this.connectionManager = connectionManager;
     this.circuitBreaker = circuitBreaker;
     this.receiveOptions = receiveOptions;
 }