private Task OnCriticalError(ICriticalErrorContext context) { var fatalMessage = $"The following critical error was encountered:\n{context.Error}\nProcess is shutting down."; Exit(fatalMessage, context.Exception); return(Task.FromResult(0)); }
Task OnCriticalError(ICriticalErrorContext context) { var fatalMessage = $"The following critical error was encountered:\n{context.Error}\nProcess is shutting down."; logger.Fatal(fatalMessage, context.Exception); Environment.FailFast(fatalMessage, context.Exception); return(Task.FromResult(0)); }
private static Task OnCriticalError(ICriticalErrorContext context) { // https://docs.particular.net/nservicebus/hosting/critical-errors var fatalMessage = $"The following critical error was encountered:\n{context.Error}\nProcess is shutting down."; Exit(fatalMessage, context.Exception); return(Task.FromResult(0)); }
// Windows hosting behavior when critical error occurs is suicide. async Task OnCriticalError(ICriticalErrorContext context) { if (Environment.UserInteractive) { await Task.Delay(10000).ConfigureAwait(false); // so that user can see on their screen the problem } Environment.FailFast("The following critical error was encountered by NServiceBus:NServiceBus is shutting down."); }
Task OnCriticalError(ICriticalErrorContext context) { // To leave the process active, stop the endpoint. return context.Stop(); // To kill the process, await the above, then raise a fail fast error as shown below. //string failMessage = string.Format("Critical error shutting down:'{0}'.", context.Error); //Environment.FailFast(failMessage, context.Exception); }
Task OnCriticalError(ICriticalErrorContext context) { // To leave the process active, stop the endpoint. return(context.Stop()); // To kill the process, await the above, then raise a fail fast error as shown below. //string failMessage = string.Format("Critical error shutting down:'{0}'.", context.Error); //Environment.FailFast(failMessage, context.Exception); }
Task OnCriticalError(ICriticalErrorContext context) { //TODO: Decide if shutting down the process is the best response to a critical error // https://docs.particular.net/nservicebus/hosting/critical-errors var fatalMessage = $"The following critical error was encountered:\n{context.Error}\nProcess is shutting down."; logger.Fatal(fatalMessage, context.Exception); Environment.FailFast(fatalMessage, context.Exception); return(Task.FromResult(0)); }
private async Task OnCriticalError(ICriticalErrorContext context) { try { await context.Stop().ConfigureAwait(false); } finally { Environment.FailFast($"Critical error, shutting down: {context.Error}", context.Exception); } }
async Task OnCriticalError(ICriticalErrorContext context) { try { await context.Stop(); } finally { FailFast($"Critical error, shutting down: {context.Error}", context.Exception); } }
static async Task OnCriticalError(ICriticalErrorContext context) { // TODO: decide if stopping the endpoint and exiting the process is the best response to a critical error // https://docs.particular.net/nservicebus/hosting/critical-errors try { await context.Stop(); } finally { FailFast($"Critical error, shutting down: {context.Error}", context.Exception); } }
private async Task OnCriticalError(ICriticalErrorContext context) { // We are intentionally exiting the process. We have Windows Service recovery to auto-restart. // https://docs.particular.net/nservicebus/hosting/critical-errors // https://docs.particular.net/nservicebus/hosting/windows-service#installation-restart-recovery try { await context.Stop(); } finally { FailFast($"Critical error, shutting down: {context.Error}", context.Exception); } }
private static async Task OnCriticalError(ICriticalErrorContext context) { var fatalMessage = $"The following critical error was encountered:{Environment.NewLine}{context.Error}{Environment.NewLine}Process is shutting down. StackTrace: {Environment.NewLine}{context.Exception.StackTrace}"; EventLog.WriteEntry(".NET Runtime", fatalMessage, EventLogEntryType.Error); try { await context.Stop().ConfigureAwait(false); } finally { Environment.FailFast(fatalMessage, context.Exception); } }
// Windows hosting behavior when critical error occurs is suicide. Task OnCriticalError(ICriticalErrorContext context) { if (Environment.UserInteractive) { Thread.Sleep(10000); // so that user can see on their screen the problem } var message = $"The following critical error was encountered by NServiceBus:\n{context.Error}\nNServiceBus is shutting down."; LogManager.GetLogger(typeof(GenericHost)).Fatal(message); Environment.FailFast(message, context.Exception); return(Task.FromResult(0)); }
static async Task OnCriticalError(ICriticalErrorContext context, CancellationToken cancellationToken) { // TODO: decide if stopping the endpoint and exiting the process is the best response to a critical error // https://docs.particular.net/nservicebus/hosting/critical-errors // and consider setting up service recovery // https://docs.particular.net/nservicebus/hosting/windows-service#installation-restart-recovery try { await context.Stop(cancellationToken); } finally { FailFast($"Critical error, shutting down: {context.Error}", context.Exception); } }
async Task OnCriticalError(ICriticalErrorContext context) { try { // To leave the process active, dispose the bus. // When the bus is disposed, the attempt to send message will cause an ObjectDisposedException. await context.Stop().ConfigureAwait(false); //Process.Start("NServiceBus.Host.exe"); } finally { Environment.FailFast($"Critical error shutting down:'{context.Error}'.", context.Exception); } }
static async Task OnCriticalError(ICriticalErrorContext context) { var fatalMessage = $"The following critical error was encountered:\n{context.Error}\nProcess is shutting down."; Logger.Fatal(fatalMessage, context.Exception); if (Environment.UserInteractive) { // so that user can see on their screen the problem await Task.Delay(10_000) .ConfigureAwait(false); } Environment.FailFast(fatalMessage, context.Exception); }
async Task OnCriticalError(ICriticalErrorContext context) { try { // To leave the process active, stop the endpoint. // When it is stopped, attempts to send messages will cause an ObjectDisposedException. await context.Stop().ConfigureAwait(false); // Perform custom actions here, e.g. // NLog.LogManager.Shutdown(); } finally { var failMessage = $"Critical error shutting down:'{context.Error}'."; Environment.FailFast(failMessage, context.Exception); } }
static Task DefaultCriticalErrorHandling(ICriticalErrorContext criticalErrorContext) { return criticalErrorContext.Stop(); }
Task OnCriticalErrorAction(ICriticalErrorContext ctx) => onCriticalError(ctx.Error, ctx.Exception);
static Task DefaultCriticalErrorHandling(ICriticalErrorContext criticalErrorContext) { return(Task.CompletedTask); }
private static Task OnCriticalError(ICriticalErrorContext arg) { Console.WriteLine("Error: " + arg.Error); return(Task.CompletedTask); }
public static Task OnCriticalError(ICriticalErrorContext criticalErrorContext) { recentFailure = criticalErrorContext.Error; return(Task.CompletedTask); }
static Task DefaultCriticalErrorHandling(ICriticalErrorContext criticalErrorContext) { return(criticalErrorContext.Stop()); }