Mark van Renswoude
74985e45de
Some are silly, like the "member not used" for public interfaces. The comments everywhere are ugly, sorry, but it keeps the possibly important issues visible without a dependency on some ReSharper annotations package.
26 lines
843 B
C#
26 lines
843 B
C#
using System.Threading.Tasks;
|
|
using Tapeti.Config;
|
|
|
|
namespace Tapeti.Flow.Default
|
|
{
|
|
public class FlowCleanupMiddleware : ICleanupMiddleware
|
|
{
|
|
public async Task Handle(IMessageContext context, HandlingResult handlingResult)
|
|
{
|
|
if (!context.Items.TryGetValue(ContextItems.FlowContext, out var flowContextObj))
|
|
return;
|
|
var flowContext = (FlowContext)flowContextObj;
|
|
|
|
if (flowContext?.FlowStateLock != null)
|
|
{
|
|
if (handlingResult.ConsumeResponse == ConsumeResponse.Nack
|
|
|| handlingResult.MessageAction == MessageAction.ErrorLog)
|
|
{
|
|
await flowContext.FlowStateLock.DeleteFlowState();
|
|
}
|
|
flowContext.FlowStateLock.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|