Fixed: delete flowstate when Exception occurs - parallellrequest
This commit is contained in:
parent
c165a8e2e6
commit
20cfedba00
@ -9,5 +9,12 @@
|
|||||||
/// Key given to the FlowContext object as stored in the message context.
|
/// Key given to the FlowContext object as stored in the message context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string FlowContext = "Tapeti.Flow.FlowContext";
|
public const string FlowContext = "Tapeti.Flow.FlowContext";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the current message handler is the last one to be called before a
|
||||||
|
/// parallel flow is done and the convergeMethod will be called.
|
||||||
|
/// Temporarily disables storing the flow state.
|
||||||
|
/// </summary>
|
||||||
|
public const string FlowIsConverging = "Tapeti.Flow.IsConverging";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,9 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
private static Task HandleParallelResponse(IControllerMessageContext context)
|
private static Task HandleParallelResponse(IControllerMessageContext context)
|
||||||
{
|
{
|
||||||
|
if (context.Get<object>(ContextItems.FlowIsConverging, out _))
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var flowHandler = context.Config.DependencyResolver.Resolve<IFlowHandler>();
|
var flowHandler = context.Config.DependencyResolver.Resolve<IFlowHandler>();
|
||||||
return flowHandler.Execute(new FlowHandlerContext(context), new DelegateYieldPoint(async flowContext =>
|
return flowHandler.Execute(new FlowHandlerContext(context), new DelegateYieldPoint(async flowContext =>
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,10 @@ namespace Tapeti.Flow.Default
|
|||||||
var converge = flowContext.FlowState.Continuations.Count == 0 &&
|
var converge = flowContext.FlowState.Continuations.Count == 0 &&
|
||||||
flowContext.ContinuationMetadata.ConvergeMethodName != null;
|
flowContext.ContinuationMetadata.ConvergeMethodName != null;
|
||||||
|
|
||||||
|
if (converge)
|
||||||
|
// Indicate to the FlowBindingMiddleware that the state must not to be stored
|
||||||
|
context.Store(ContextItems.FlowIsConverging, null);
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
|
|
||||||
if (converge)
|
if (converge)
|
||||||
@ -57,6 +61,7 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
if (flowContext?.FlowStateLock != null)
|
if (flowContext?.FlowStateLock != null)
|
||||||
{
|
{
|
||||||
|
// TODO do not call when the controller method was filtered, if the same message has two methods
|
||||||
if (!flowContext.IsStoredOrDeleted())
|
if (!flowContext.IsStoredOrDeleted())
|
||||||
// The exception strategy can set the consume result to Success. Instead, check if the yield point
|
// The exception strategy can set the consume result to Success. Instead, check if the yield point
|
||||||
// was handled. The flow provider ensures we only end up here in case of an exception.
|
// was handled. The flow provider ensures we only end up here in case of an exception.
|
||||||
|
Loading…
Reference in New Issue
Block a user