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:
parent
625c80e8f7
commit
355c992dbf
29
Tapeti.Flow/Default/FlowCleanupMiddleware.cs
Normal file
29
Tapeti.Flow/Default/FlowCleanupMiddleware.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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" />
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user