2b56d0130e
Flow ruimt nu zijn locks goed op en de weggeschreven state ingeval van exceptions tijdens het afhandelen van de message
30 lines
853 B
C#
30 lines
853 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, ConsumeResponse response)
|
|
{
|
|
object flowContextObj;
|
|
if (!context.Items.TryGetValue(ContextItems.FlowContext, out flowContextObj))
|
|
return;
|
|
var flowContext = (FlowContext)flowContextObj;
|
|
|
|
if (flowContext.FlowStateLock != null)
|
|
{
|
|
if (response == ConsumeResponse.Nack)
|
|
{
|
|
await flowContext.FlowStateLock.DeleteFlowState();
|
|
}
|
|
flowContext.FlowStateLock.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|