-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConsumerGrain.cs
More file actions
48 lines (38 loc) · 1.12 KB
/
ConsumerGrain.cs
File metadata and controls
48 lines (38 loc) · 1.12 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
41
42
43
44
45
46
47
48
namespace OrleansMissingEvents
{
using Orleans.Runtime;
using Orleans.Streams;
internal class ConsumerGrain : Grain, IConsumerGrain
{
public async Task ExplicitSubscribe(Guid modelId)
{
var self = this.AsReference<IConsumerGrain>();
await Task.Run(() =>
{
self.DoWork();
});
await this.GetStreamProvider("TestStream")
.GetStream<int>(StreamId.Create("ns", modelId))
.SubscribeAsync(this);
Console.WriteLine("Subscribe Complete");
}
public async Task DoWork()
{
await Task.Delay(300);
}
public Task OnNextAsync(int item, StreamSequenceToken? token = null)
{
Console.WriteLine($"Received event: {item}.");
return Task.CompletedTask;
}
public Task OnCompletedAsync()
{
return Task.CompletedTask;
}
public Task OnErrorAsync(Exception ex)
{
Console.WriteLine("Got error");
return Task.CompletedTask;
}
}
}