-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (29 loc) · 1.3 KB
/
Program.cs
File metadata and controls
40 lines (29 loc) · 1.3 KB
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
namespace OrleansMissingEvents
{
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
internal class Program
{
static async Task Main(string[] args)
{
var siloHostBuilder = new HostBuilder().UseOrleans(siloBuilder =>
{
siloBuilder
.UseLocalhostClustering()
.AddMemoryGrainStorage("PubSubStore")
.AddMemoryStreams("TestStream");
});
var host = siloHostBuilder.Build();
await host.StartAsync();
var grainFactory = host.Services.GetRequiredService<IGrainFactory>();
var producerId = Guid.NewGuid();
var producerGrain = grainFactory.GetGrain<IProducerGrain>(producerId);
var consumerGrain = grainFactory.GetGrain<IConsumerGrain>(Guid.NewGuid());
await producerGrain.WakeUpStream(); // Ensure stream is initialized in PersistentStreamPullingAgent.
await Task.Delay(1000); // Wait for that initial event from the WakeUpStream call to settle.
await consumerGrain.ExplicitSubscribe(producerId); // Subscribe to the stream.
await producerGrain.EmitEventsAsync(); // Emit more events.
Console.ReadLine();
}
}
}