forked from MassTransit/MassTransit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5b2bed
commit a0fd4b4
Showing
3 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
doc/content/3.documentation/3.patterns/7.routing-slips/_dir.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
title: Routing Slips |
50 changes: 50 additions & 0 deletions
50
doc/content/3.documentation/3.patterns/7.routing-slips/monitor-via-saga.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: Monitor via Saga | ||
--- | ||
|
||
# How to Monitor a Routing Slip with a Saga | ||
|
||
Because Routing Slips carry their state on the wire, it's not possible to query the state of a currently executing routing slip. Use this pattern when your solution requires tracking the progress of a Routing Slip that's in-flight. | ||
|
||
## Create a Normal Routing Slip | ||
|
||
```csharp | ||
var builder = new RoutingSlipBuilder(NewId.NextGuid()); | ||
|
||
// add your activities as normal | ||
builder.AddActivity("DownloadImage", new Uri("rabbitmq://localhost/execute_downloadimage"), | ||
new | ||
{ | ||
ImageUri = new Uri("http://images.google.com/someImage.jpg") | ||
}); | ||
builder.AddActivity("FilterImage", new Uri("rabbitmq://localhost/execute_filterimage")); | ||
builder.AddVariable("WorkPath", @"\dfs\work"); | ||
|
||
var routingSlip = builder.Build(); | ||
``` | ||
|
||
## Build the Saga | ||
|
||
```csharp | ||
public class MonitorRoutingSlip : | ||
MassTransitStateMachine<MonitorState> | ||
{ | ||
public MonitorRoutingSlip() | ||
{ | ||
InstanceState(x => x.CurrentState); | ||
} | ||
} | ||
``` | ||
|
||
## Add Subscription to Routing Slip | ||
|
||
```csharp | ||
var builder = new RoutingSlipBuilder(NewId.NextGuid()); | ||
|
||
// ... add activities and variables as normal | ||
// ⭐️ KEY ITEM | ||
builder.AddSubscription(new Uri("<the saga queue>"), RoutingSlipEvents.All); | ||
|
||
var routingSlip = builder.Build(); | ||
``` |