public override async Task ReceiveAsync(IContext context) { Task task = context.Message switch { PingCmd cmd => HandlePing(context, cmd), ExceptionPoison cmd => HandleExceptionPoison(context, cmd), NoAnswerPoison cmd => HandleNoAnswerPoison(context, cmd), SleepPoison cmd => HandleSleepPoison(context, cmd), Started _ => Started(context), _ => base.ReceiveAsync(context) }; try { await task; } catch (Exception e) { this.logger.LogError(e, "Failed PingGrain"); context.Respond(new DeadLetterResponse { Target = context.Self }); } }
public Task HandleExceptionPoison(IContext context, ExceptionPoison cmd) { logger.LogInformation($"PongGrain.HandleExceptionPoison"); try { this.exceptionCounter++; context.Respond(new PoisonResponse()); return(Task.CompletedTask); } catch (Exception e) { this.logger.LogError(e, "Failed in HandleExceptionPoison"); context.Respond(new PoisonResponse()); } return(Task.CompletedTask); }