private void OnHostShutdownTriggered() { log.Info("Hosting shutdown has been initiated. Timeout = {HostingShutdownTimeout}.", totalTimeout); if (sendAnnotation) { AnnotationsHelper.ReportStopping(identity, instanceMetrics); } hostShutdownBudget.Start(); ShutdownBeaconAsync().ContinueWith(_ => appShutdown.Initiate(hostShutdownBudget.Remaining)); }
public void InvokeChannelAction(Action <IModel> channelAction) { Preconditions.CheckNotNull(channelAction, "channelAction"); var timeout = configuration.Timeout.Equals(0) ? TimeBudget.Infinite() : TimeBudget.Start(TimeSpan.FromSeconds(configuration.Timeout)); var retryTimeoutMs = MinRetryTimeoutMs; while (!timeout.IsExpired()) { try { var channel = OpenChannel(); channelAction(channel); return; } catch (OperationInterruptedException exception) { CloseChannel(); if (NeedRethrow(exception)) { throw; } } catch (EasyNetQException) { CloseChannel(); } Thread.Sleep(retryTimeoutMs); retryTimeoutMs = Math.Min(retryTimeoutMs * 2, MaxRetryTimeoutMs); } logger.Error("Channel action timed out"); throw new TimeoutException("The operation requested on PersistentChannel timed out"); }