public Task HandleRestartPoison(IContext context, RestartPoison cmd) { logger.LogInformation($"PoisonGrain.RestartPoison"); try { context.Respond(new PoisonResponse()); //Environment.Exit(-1); ForceShutdown.appLifetime.StopApplication(); return(Task.CompletedTask); } catch (Exception e) { this.logger.LogError(e, "Failed in PoisonGrain"); context.Respond(new PoisonResponse()); } return(Task.CompletedTask); }
public override async Task ReceiveAsync(IContext context) { Task task = context.Message switch { BroadcastPoison cmd => HandleBroadcastPoison(context, cmd), RestartPoison cmd => HandleRestartPoison(context, cmd), Started _ => Started(context), _ => base.ReceiveAsync(context) }; try { await task; } catch (Exception e) { this.logger.LogError(e, "Failed PoisonGrain"); context.Respond(new DeadLetterResponse { Target = context.Self }); } }