@@ -55,7 +55,7 @@ protected override async Task ProcessItem(string itemId, CancellationToken cance
55
55
finally
56
56
{
57
57
WorkflowActivity . Enrich ( result ) ;
58
- await _persistenceStore . PersistWorkflow ( workflow , result . Subscriptions , cancellationToken ) ;
58
+ await _persistenceStore . PersistWorkflow ( workflow , result . Subscriptions ) ;
59
59
await QueueProvider . QueueWork ( itemId , QueueType . Index ) ;
60
60
_greylist . Remove ( $ "wf:{ itemId } ") ;
61
61
}
@@ -68,10 +68,10 @@ protected override async Task ProcessItem(string itemId, CancellationToken cance
68
68
{
69
69
foreach ( var sub in result . Subscriptions )
70
70
{
71
- await TryProcessSubscription ( sub , _persistenceStore , cancellationToken ) ;
71
+ await TryProcessSubscription ( sub , _persistenceStore ) ;
72
72
}
73
73
74
- await _persistenceStore . PersistErrors ( result . Errors , cancellationToken ) ;
74
+ await _persistenceStore . PersistErrors ( result . Errors ) ;
75
75
76
76
if ( ( workflow . Status == WorkflowStatus . Runnable ) && workflow . NextExecution . HasValue )
77
77
{
@@ -98,24 +98,28 @@ await _persistenceStore.ScheduleCommand(new ScheduledCommand()
98
98
99
99
}
100
100
101
- private async Task TryProcessSubscription ( EventSubscription subscription , IPersistenceProvider persistenceStore , CancellationToken cancellationToken )
101
+ private async Task TryProcessSubscription ( EventSubscription subscription , IPersistenceProvider persistenceStore )
102
102
{
103
+ //TODO: move to own class
104
+ Logger . LogDebug ( "Subscribing to event {0} {1} for workflow {2} step {3}" , subscription . EventName , subscription . EventKey , subscription . WorkflowId , subscription . StepId ) ;
105
+
106
+ await persistenceStore . CreateEventSubscription ( subscription , cancellationToken ) ;
103
107
if ( subscription . EventName != Event . EventTypeActivity )
104
108
{
105
- var events = await persistenceStore . GetEvents ( subscription . EventName , subscription . EventKey , subscription . SubscribeAsOf , cancellationToken ) ;
109
+ var events = await persistenceStore . GetEvents ( subscription . EventName , subscription . EventKey , subscription . SubscribeAsOf ) ;
106
110
107
111
foreach ( var evt in events )
108
112
{
109
113
var eventKey = $ "evt:{ evt } ";
110
114
bool acquiredLock = false ;
111
115
try
112
116
{
113
- acquiredLock = await _lockProvider . AcquireLock ( eventKey , cancellationToken ) ;
117
+ acquiredLock = await _lockProvider . AcquireLock ( eventKey , CancellationToken . None ) ;
114
118
int attempt = 0 ;
115
119
while ( ! acquiredLock && attempt < 10 )
116
120
{
117
- await Task . Delay ( Options . IdleTime , cancellationToken ) ;
118
- acquiredLock = await _lockProvider . AcquireLock ( eventKey , cancellationToken ) ;
121
+ await Task . Delay ( Options . IdleTime ) ;
122
+ acquiredLock = await _lockProvider . AcquireLock ( eventKey , CancellationToken . None ) ;
119
123
120
124
attempt ++ ;
121
125
}
@@ -127,7 +131,7 @@ private async Task TryProcessSubscription(EventSubscription subscription, IPersi
127
131
else
128
132
{
129
133
_greylist . Remove ( eventKey ) ;
130
- await persistenceStore . MarkEventUnprocessed ( evt , cancellationToken ) ;
134
+ await persistenceStore . MarkEventUnprocessed ( evt ) ;
131
135
await QueueProvider . QueueWork ( evt , QueueType . Event ) ;
132
136
}
133
137
}
0 commit comments