Skip to content

Commit 51e5486

Browse files
committed
Extend snippet with not found handler mapping
1 parent c993fda commit 51e5486

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

Snippets/Core/Core_10/Core_10.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
14-
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.20" />
14+
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.21" />
1515
<PackageReference Include="NServiceBus.Callbacks" Version="6.0.0-alpha.3" />
1616
<PackageReference Include="NServiceBus.ClaimCheck" Version="2.0.0-alpha.5" />
1717
<PackageReference Include="NServiceBus.Encryption.MessageProperty" Version="6.0.0-alpha.3" />

Snippets/Core/Core_10/Sagas/SagaNotFoundHandler.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,43 @@ public Task Handle(object message, IMessageProcessingContext context)
1616
}
1717
}
1818

19-
public class SagaDisappearedMessage
19+
public class SagaDisappearedMessage;
20+
21+
class SagaUsingNotFoundHandler : Saga<NotFoundSagaData>, IAmStartedByMessages<StartSagaMessage>, IHandleMessages<AnotherSagaMessage>
22+
{
23+
protected override void ConfigureHowToFindSaga(SagaPropertyMapper<NotFoundSagaData> mapper)
24+
{
25+
mapper.ConfigureNotFoundHandler<SagaNotFoundHandler>();
26+
#endregion
27+
mapper.MapSaga(saga => saga.CorrelationId)
28+
.ToMessage<StartSagaMessage>(msg => msg.CorrelationId);
29+
}
30+
31+
public Task Handle(StartSagaMessage message, IMessageHandlerContext context)
32+
{
33+
Data.CorrelationId = message.CorrelationId;
34+
return Task.CompletedTask;
35+
}
36+
37+
public Task Handle(AnotherSagaMessage message, IMessageHandlerContext context)
38+
{
39+
MarkAsComplete();
40+
return Task.CompletedTask;
41+
}
42+
}
43+
44+
45+
class AnotherSagaMessage;
46+
47+
class StartSagaMessage
2048
{
49+
public Guid CorrelationId { get; set; }
2150
}
2251

23-
#endregion
52+
class NotFoundSagaData : ContainSagaData
53+
{
54+
public Guid CorrelationId { get; set; }
55+
}
2456

2557
#region saga-not-found-error-queue
2658
public sealed class SagaNotFoundException : Exception

0 commit comments

Comments
 (0)