Skip to content

Commit e67e98c

Browse files
Greylist fixes in workflow consumer
1 parent 91ee43d commit e67e98c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/WorkflowCore/Services/BackgroundTasks/WorkflowConsumer.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private async Task SubscribeEvent(EventSubscription subscription, IPersistencePr
8484
{
8585
//TODO: move to own class
8686
Logger.LogDebug("Subscribing to event {0} {1} for workflow {2} step {3}", subscription.EventName, subscription.EventKey, subscription.WorkflowId, subscription.StepId);
87-
87+
8888
await persistenceStore.CreateEventSubscription(subscription, cancellationToken);
8989
if (subscription.EventName != Event.EventTypeActivity)
9090
{
@@ -101,13 +101,21 @@ private async Task SubscribeEvent(EventSubscription subscription, IPersistencePr
101101
while (!acquiredLock && attempt < 10)
102102
{
103103
acquiredLock = await _lockProvider.AcquireLock(eventKey, cancellationToken);
104-
await Task.Delay(Options.IdleTime);
104+
await Task.Delay(Options.IdleTime, cancellationToken);
105105

106106
attempt++;
107107
}
108108

109-
await persistenceStore.MarkEventUnprocessed(evt, cancellationToken);
110-
await QueueProvider.QueueWork(evt, QueueType.Event);
109+
if (!acquiredLock)
110+
{
111+
Logger.LogWarning($"Failed to lock {evt}");
112+
}
113+
else
114+
{
115+
await persistenceStore.MarkEventUnprocessed(evt, cancellationToken);
116+
await QueueProvider.QueueWork(evt, QueueType.Event);
117+
_greylist.Remove(eventKey);
118+
}
111119
}
112120
finally
113121
{

0 commit comments

Comments
 (0)