-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
55 lines (46 loc) · 1.77 KB
/
Program.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using NServiceBus.AuditFilter;
class Program
{
public static string AuditPath = Path.GetFullPath("../.learningtransport/audit");
static async Task Main()
{
Console.Title = "Samples.AuditFilter";
var endpointConfiguration = new EndpointConfiguration("Samples.AuditFilter");
endpointConfiguration.UsePersistence<LearningPersistence>();
endpointConfiguration.UseTransport<LearningTransport>();
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
#region Enable
endpointConfiguration.AuditProcessedMessagesTo("audit");
endpointConfiguration.FilterAuditQueue(
defaultFilter: FilterResult.IncludeInAudit);
#endregion
var endpoint = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Console.WriteLine($"Audit Path:\r\n{AuditPath}");
Console.WriteLine("Press E to send a message that will be excluded");
Console.WriteLine("Press I to send a message that will be included");
Console.WriteLine("Press any other key to exit");
while (true)
{
Console.WriteLine();
var key = Console.ReadKey();
if (key.Key == ConsoleKey.I)
{
var message = new MessageToIncludeAudit();
await endpoint.SendLocal(message)
.ConfigureAwait(false);
continue;
}
if (key.Key == ConsoleKey.E)
{
var message = new MessageToExcludeFromAudit();
await endpoint.SendLocal(message)
.ConfigureAwait(false);
continue;
}
break;
}
await endpoint.Stop()
.ConfigureAwait(false);
}
}