Exemplo n.º 1
0
        protected override async Task ProcessItem(string itemId, CancellationToken cancellationToken)
        {
            if (await _lockProvider.AcquireLock($"evt:{itemId}", cancellationToken))
            {
                try
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    var evt = await _persistenceStore.GetEvent(itemId);

                    if (evt.EventTime <= _datetimeProvider.Now.ToUniversalTime())
                    {
                        var subs = await _persistenceStore.GetSubscriptions(evt.EventName, evt.EventKey, evt.EventTime);

                        var success = true;

                        foreach (var sub in subs.ToList())
                        {
                            success = success && await SeedSubscription(evt, sub, cancellationToken);
                        }

                        if (success)
                        {
                            await _persistenceStore.MarkEventProcessed(itemId);
                        }
                    }
                }
                finally
                {
                    await _lockProvider.ReleaseLock($"evt:{itemId}");
                }
            }
            else
            {
                Logger.LogInformation($"Event locked {itemId}");
            }
        }
Exemplo n.º 2
0
 protected IEnumerable <EventSubscription> GetActiveSubscriptons(string eventName, string eventKey)
 {
     return(PersistenceProvider.GetSubscriptions(eventName, eventKey, DateTime.MaxValue).Result);
 }