Beispiel #1
0
        void ExecutePollingLoop(object ignored)
        {
            var retry    = RetryPolicy.Create();
            var sleepFor = TimeSpan.Zero;

            while (working)
            {
                try
                {
                    try
                    {
                        retry.Try();
                        secureClient.ExecuteTransaction(protocol => { protocol.ExchangeAsSubscriber(subscription, handleIncomingRequest); }, cancellationToken);
                        retry.Success();
                    }
                    finally
                    {
                        sleepFor = retry.GetSleepPeriod();
                    }
                }
                catch (HalibutClientException ex)
                {
                    log?.WriteException(EventType.Error, $"Halibut client exception: {ex.Message?.TrimEnd('.')}. Retrying in {sleepFor.TotalSeconds:n1} seconds", ex);
                }
                catch (Exception ex)
                {
                    log?.WriteException(EventType.Error, $"Exception in the polling loop. Retrying in {sleepFor.TotalSeconds:n1} seconds. This may be cause by a network error and usually rectifies itself. Disregard this message unless you are having communication problems.", ex);
                }
                finally
                {
                    Thread.Sleep(sleepFor);
                }
            }
        }
Beispiel #2
0
        private void ExecutePollingLoop(object ignored)
        {
            var retry = new PhasedBackoffRetryTracker();

            while (working)
            {
                try
                {
                    retry.Try();
                    secureClient.ExecuteTransaction(protocol =>
                    {
                        protocol.ExchangeAsSubscriber(subscription, handleIncomingRequest);
                    });
                    retry.Success();
                }
                catch (HalibutClientException hce)
                {
                    var sleepFor = retry.GetSleepPeriod();
                    log?.Write(EventType.Error, $"{hce.Message?.TrimEnd('.')}. Retrying in {sleepFor.TotalSeconds:n1} seconds");
                    Thread.Sleep(sleepFor);
                }
                catch (Exception ex)
                {
                    log?.WriteException(EventType.Error, "Exception in the polling loop, sleeping for 5 seconds. This may be cause by a network error and usually rectifies itself. Disregard this message unless you are having communication problems.", ex);
                    Thread.Sleep(5000);
                }
            }
        }
 private void ExecutePollingLoop(object ignored)
 {
     while (working)
     {
         try
         {
             secureClient.ExecuteTransaction(protocol =>
             {
                 protocol.ExchangeAsSubscriber(subscription, handleIncomingRequest);
             });
         }
         catch (Exception)
         {
             Thread.Sleep(5000);
         }
     }
 }
Beispiel #4
0
 private void ExecutePollingLoop(object ignored)
 {
     while (working)
     {
         try
         {
             secureClient.ExecuteTransaction(protocol =>
             {
                 protocol.ExchangeAsSubscriber(subscription, handleIncomingRequest);
             });
         }
         catch (Exception ex)
         {
             log?.WriteException(EventType.Error, "Exception in the polling loop, sleeping for 5 seconds. This may be cause by a network error and usually rectifies itself. Disregard this message unless you are having communication problems.", ex);
             Thread.Sleep(5000);
         }
     }
 }