Skip to content

Commit

Permalink
Merge pull request #1123 from glucaci/fixMongoPersistWorkflow
Browse files Browse the repository at this point in the history
[Bug] Fix MongoDB persist workflow when no subscription
  • Loading branch information
danielgerlag committed Dec 12, 2022
2 parents 30781e3 + 86ed4fa commit 41b85c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<PackageLicenseUrl>https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/danielgerlag/workflow-core.git</RepositoryUrl>
<Version>3.8.0</Version>
<AssemblyVersion>3.8.0.0</AssemblyVersion>
<FileVersion>3.8.0.0</FileVersion>
<Version>3.8.1</Version>
<AssemblyVersion>3.8.1.0</AssemblyVersion>
<FileVersion>3.8.1.0</FileVersion>
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
<PackageVersion>3.8.0</PackageVersion>
<PackageVersion>3.8.1</PackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override async Task ProcessItem(string itemId, CancellationToken cance
finally
{
WorkflowActivity.Enrich(result);
await _persistenceStore.PersistWorkflow(workflow, result.Subscriptions, cancellationToken);
await _persistenceStore.PersistWorkflow(workflow, result?.Subscriptions, cancellationToken);
await QueueProvider.QueueWork(itemId, QueueType.Index);
_greylist.Remove($"wf:{itemId}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,18 @@ public async Task PersistWorkflow(WorkflowInstance workflow, CancellationToken c

public async Task PersistWorkflow(WorkflowInstance workflow, List<EventSubscription> subscriptions, CancellationToken cancellationToken = default)
{
using (var session = await _database.Client.StartSessionAsync())
if (subscriptions == null || subscriptions.Count < 1)
{
await PersistWorkflow(workflow, cancellationToken);
return;
}

using (var session = await _database.Client.StartSessionAsync(cancellationToken: cancellationToken))
{
session.StartTransaction();
await PersistWorkflow(workflow, cancellationToken);
await EventSubscriptions.InsertManyAsync(subscriptions, cancellationToken: cancellationToken);
await session.CommitTransactionAsync();
await session.CommitTransactionAsync(cancellationToken);
}
}

Expand Down

0 comments on commit 41b85c3

Please sign in to comment.