Possible fix for #21 - Same request/response twice in flow does not continue?
This commit is contained in:
parent
c6700b2697
commit
13833040e8
@ -52,16 +52,19 @@ namespace Tapeti.Flow.Default
|
||||
}
|
||||
|
||||
|
||||
public async Task Cleanup(IMessageContext context, ConsumeResult consumeResult, Func<Task> next)
|
||||
public async Task Cleanup(IControllerMessageContext context, ConsumeResult consumeResult, Func<Task> next)
|
||||
{
|
||||
await next();
|
||||
|
||||
if (!context.Get(ContextItems.FlowContext, out FlowContext flowContext))
|
||||
return;
|
||||
|
||||
if (flowContext.ContinuationMetadata.MethodName != MethodSerializer.Serialize(context.Binding.Method))
|
||||
// Do not call when the controller method was filtered, if the same message has two methods
|
||||
return;
|
||||
|
||||
if (flowContext?.FlowStateLock != null)
|
||||
{
|
||||
// TODO do not call when the controller method was filtered, if the same message has two methods
|
||||
if (!flowContext.IsStoredOrDeleted())
|
||||
// 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.
|
||||
|
@ -14,6 +14,6 @@ namespace Tapeti.Config
|
||||
/// <param name="context"></param>
|
||||
/// <param name="consumeResult"></param>
|
||||
/// <param name="next">Always call to allow the next in the chain to clean up</param>
|
||||
Task Cleanup(IMessageContext context, ConsumeResult consumeResult, Func<Task> next);
|
||||
Task Cleanup(IControllerMessageContext context, ConsumeResult consumeResult, Func<Task> next);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
public interface IControllerMessageContext : IMessageContext
|
||||
{
|
||||
/// <summary>
|
||||
/// An instance of the controller referenced by the binding.
|
||||
/// An instance of the controller referenced by the binding. Note: is null during Cleanup.
|
||||
/// </summary>
|
||||
object Controller { get; }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -182,10 +182,16 @@ namespace Tapeti.Default
|
||||
/// <inheritdoc />
|
||||
public async Task Cleanup(IMessageContext context, ConsumeResult consumeResult)
|
||||
{
|
||||
await MiddlewareHelper.GoAsync(
|
||||
bindingInfo.CleanupMiddleware,
|
||||
async (handler, next) => await handler.Cleanup(context, consumeResult, next),
|
||||
() => Task.CompletedTask);
|
||||
using (var controllerContext = new ControllerMessageContext(context)
|
||||
{
|
||||
Controller = null
|
||||
})
|
||||
{
|
||||
await MiddlewareHelper.GoAsync(
|
||||
bindingInfo.CleanupMiddleware,
|
||||
async (handler, next) => await handler.Cleanup(controllerContext, consumeResult, next),
|
||||
() => Task.CompletedTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user