-
Notifications
You must be signed in to change notification settings - Fork 64
/
S09_Handling_duplicates.cs
33 lines (29 loc) · 1.06 KB
/
S09_Handling_duplicates.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Linq;
using Streamstone;
namespace Example.Scenarios
{
public class S09_Handling_duplicates : Scenario
{
public override void Run()
{
var result = Stream.Write(new Stream(Partition), new[]{new EventData(id: "42")});
try
{
var events = new[]
{
new EventData(id: "56"),
new EventData(id: "42") // conflicting (duplicate) event
};
Stream.Write(result.Stream, events);
}
catch (DuplicateEventException e)
{
Console.WriteLine("Idempotency is based on ID of the event.");
Console.WriteLine("An ID of conflicting event will be reported back as a property of DuplicateEventException.");
Console.WriteLine("Here the conflicting event is: {0}", e.Id);
Console.WriteLine("The caller can use this information to remove conflicting event from the batch and retry");
}
}
}
}