/// <inheritdoc /> public async Task Execute(IFlowHandlerContext context, IYieldPoint yieldPoint) { if (!(yieldPoint is DelegateYieldPoint executableYieldPoint)) { throw new YieldPointException($"Yield point is required in controller {context.Controller.GetType().Name} for method {context.Method.Name}"); } FlowContext flowContext = null; var disposeFlowContext = false; try { var messageContext = context.ControllerMessageContext; if (messageContext == null || !messageContext.Get(ContextItems.FlowContext, out flowContext)) { flowContext = new FlowContext { HandlerContext = context }; // If we ended up here it is because of a Start. No point in storing the new FlowContext // in the messageContext as the yield point is the last to execute. disposeFlowContext = true; } try { await executableYieldPoint.Execute(flowContext); } catch (YieldPointException e) { // Useful for debugging e.Data["Tapeti.Controller.Name"] = context.Controller.GetType().FullName; e.Data["Tapeti.Controller.Method"] = context.Method.Name; throw; } flowContext.EnsureStoreOrDeleteIsCalled(); } finally { if (disposeFlowContext) { flowContext.Dispose(); } } }
private static ReplyMetadata GetReply(IFlowHandlerContext context) { var requestAttribute = context.ControllerMessageContext?.Message?.GetType().GetCustomAttribute <RequestAttribute>(); if (requestAttribute?.Response == null) { return(null); } return(new ReplyMetadata { CorrelationId = context.ControllerMessageContext.Properties.CorrelationId, ReplyTo = context.ControllerMessageContext.Properties.ReplyTo, ResponseTypeName = requestAttribute.Response.FullName, Mandatory = context.ControllerMessageContext.Properties.Persistent.GetValueOrDefault(true) }); }