1
0
mirror of synced 2024-06-29 23:37:40 +00:00
Tapeti/Tapeti.Flow/Default/FlowCleanupMiddleware.cs
Menno van Lavieren ee86e2c739 RDB-136 Flow tabel wordt niet meer opgeruimd Bij een exceptie in Flow
Refactoring om de actie van de Exceptionstrategie door te geven aan de cleanup stack
2017-10-17 13:29:16 +02:00

31 lines
960 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tapeti.Config;
namespace Tapeti.Flow.Default
{
public class FlowCleanupMiddleware : ICleanupMiddleware
{
public async Task Handle(IMessageContext context, HandlingResult handlingResult)
{
object flowContextObj;
if (!context.Items.TryGetValue(ContextItems.FlowContext, out 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();
}
}
}
}