Skip to content

Commit 66fc797

Browse files
committed
Add transaction scope support
1 parent 1efecab commit 66fc797

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using WorkflowCore.Interface;
1313
using WorkflowCore.Models;
1414
using System.Threading;
15+
using MongoDB.Extensions.Transactions;
1516

1617
namespace WorkflowCore.Persistence.MongoDB.Services
1718
{
@@ -115,13 +116,13 @@ static void CreateIndexes(MongoPersistenceProvider instance)
115116
}
116117
}
117118

118-
private IMongoCollection<WorkflowInstance> WorkflowInstances => _database.GetCollection<WorkflowInstance>(WorkflowCollectionName);
119+
private IMongoCollection<WorkflowInstance> WorkflowInstances => _database.GetCollection<WorkflowInstance>(WorkflowCollectionName).AsTransactionCollection();
119120

120-
private IMongoCollection<EventSubscription> EventSubscriptions => _database.GetCollection<EventSubscription>("wfc.subscriptions");
121+
private IMongoCollection<EventSubscription> EventSubscriptions => _database.GetCollection<EventSubscription>("wfc.subscriptions").AsTransactionCollection();
121122

122-
private IMongoCollection<Event> Events => _database.GetCollection<Event>("wfc.events");
123+
private IMongoCollection<Event> Events => _database.GetCollection<Event>("wfc.events").AsTransactionCollection();
123124

124-
private IMongoCollection<ExecutionError> ExecutionErrors => _database.GetCollection<ExecutionError>("wfc.execution_errors");
125+
private IMongoCollection<ExecutionError> ExecutionErrors => _database.GetCollection<ExecutionError>("wfc.execution_errors").AsTransactionCollection();
125126

126127
public async Task<string> CreateNewWorkflow(WorkflowInstance workflow, CancellationToken cancellationToken = default)
127128
{

src/providers/WorkflowCore.Persistence.MongoDB/WorkflowCore.Persistence.MongoDB.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="MongoDB.Driver" Version="2.8.1" />
25+
<PackageReference Include="MongoDB.Driver" Version="2.12.2" />
26+
<PackageReference Include="MongoDB.Extensions.Transactions" Version="0.8.0" />
2627
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
2728
</ItemGroup>
2829

0 commit comments

Comments
 (0)