1
0
mirror of synced 2024-11-05 11:09:17 +00:00

RDB-136 Flow tabel wordt niet meer opgeruimd Bij een exceptie in Flow

Flow ruimt nu zijn locks goed op en de weggeschreven state ingeval van exceptions tijdens het afhandelen van de message
This commit is contained in:
Menno van Lavieren 2017-10-13 13:49:47 +02:00
parent 625c80e8f7
commit 355c992dbf
4 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,29 @@
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();
}
}
}
}

View File

@ -24,7 +24,8 @@ namespace Tapeti.Flow
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver) public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
{ {
return new[] { new FlowBindingMiddleware() }; yield return new FlowBindingMiddleware();
yield return new FlowCleanupMiddleware();
} }
} }
} }

View File

@ -54,6 +54,7 @@
<Compile Include="Annotations\ContinuationAttribute.cs" /> <Compile Include="Annotations\ContinuationAttribute.cs" />
<Compile Include="Annotations\StartAttribute.cs" /> <Compile Include="Annotations\StartAttribute.cs" />
<Compile Include="ContextItems.cs" /> <Compile Include="ContextItems.cs" />
<Compile Include="Default\FlowCleanupMiddleware.cs" />
<Compile Include="Default\FlowMessageFilterMiddleware.cs" /> <Compile Include="Default\FlowMessageFilterMiddleware.cs" />
<Compile Include="Default\FlowBindingMiddleware.cs" /> <Compile Include="Default\FlowBindingMiddleware.cs" />
<Compile Include="Default\FlowContext.cs" /> <Compile Include="Default\FlowContext.cs" />

View File

@ -129,6 +129,8 @@ namespace Tapeti.Connection
if (message == null) if (message == null)
throw new ArgumentException("Empty message"); throw new ArgumentException("Empty message");
context.Message = message;
var validMessageType = false; var validMessageType = false;
foreach (var binding in bindings) foreach (var binding in bindings)