public static async Task Go(DbConnection connection, EventQueueItem item, IServiceProvider provider, DbTransaction transaction) { var type = Type.GetType(item.Action); BaseTask resolved = null; try { if (type != null) { resolved = (BaseTask)ActivatorUtilities.CreateInstance(provider, type, item); await resolved.Go(); } await connection.ExecuteAsync("DELETE from \"EventQueue\" where \"Id\" = @Id", new { Id = item.Id }); transaction.Commit(); } catch (Exception e) { Console.WriteLine(e); // failed item.AttemptCount++; item.NextAttempt = resolved.NextTry(item.AttemptCount); transaction.Rollback(); await connection.ExecuteAsync("UPDATE \"EventQueue\" set \"AttemptCount\"=@AttemptCount, \"NextAttempt\"=@NextAttempt where \"Id\" = @Id", new { Attemptcount = item.AttemptCount, NextAttempt = item.NextAttempt, Id = item.Id }); } transaction.Dispose(); }
private void HandleEventInsert(TAggregate aggregateRoot, SqlConnection con, SqlTransaction tran) { foreach (var evnt in aggregateRoot.UncommittedChanges()) { var eventData = EventQueueItem.Serialize(evnt, typeof(TAggregate).Name, Guid.NewGuid()); con.Execute($"insert into [Messaging].[EventQueue] values ('{eventData.AggregateRootId}','{eventData.CorrelationId}','{eventData.EventName}','{eventData.OccuredOn}','{eventData.Payload}','{eventData.AggregateName}')", transaction: tran); } }
public DeliverToActivityPubTask(EventQueueItem item, IEntityStore entityStore, EntityFlattener entityFlattener, IServiceProvider serviceProvider, DeliveryService deliveryService, APContext context, EntityData data) : base(item) { _entityStore = entityStore; _entityFlattener = entityFlattener; _serviceProvider = serviceProvider; _deliveryService = deliveryService; _context = context; _data = data; }
public DeliverToActivityPubTask(EventQueueItem item, IEntityStore entityStore, EntityFlattener entityFlattener, IServiceProvider serviceProvider, DeliveryService deliveryService, SignatureVerifier verifier, KeyService keyService) : base(item) { _entityStore = entityStore; _entityFlattener = entityFlattener; _serviceProvider = serviceProvider; _deliveryService = deliveryService; _verifier = verifier; _keyService = keyService; }
public static Data.EventQueueItem ToXferData(this EventQueueItem item) { return(new Data.EventQueueItem { UserId = item.User.Id, StartTime = item.StartTime, EndTime = item.EndTime, RandomlySelected = item.RandomlySelected, }); }
public static async Task Go(APContext context, EventQueueItem item, IServiceProvider provider) { var type = Type.GetType("Kroeg.Server.BackgroundTasks." + item.Action); var resolved = (BaseTask)ActivatorUtilities.CreateInstance(provider, type, item); try { await resolved.Go(); context.EventQueue.Remove(item); } catch (Exception) { // failed item.AttemptCount++; item.NextAttempt = resolved.NextTry(item.AttemptCount); } await context.SaveChangesAsync(); }
private async Task ProcessEventQueue(IThreadLoopEvent loopEvent) { while (true) { EventQueueItem item = null; var didDequeue = _queue.TryDequeue(out item); if (!didDequeue) { return; } FireEvent(item.Event); if (loopEvent.IsCancelled) { break; } } await Task.CompletedTask; }
public DeliverToWebSubTask(EventQueueItem item, IEntityStore entityStore, AtomEntryGenerator entryGenerator, DbConnection connection) : base(item) { _entityStore = entityStore; _entryGenerator = entryGenerator; _connection = connection; }
protected BaseTask(EventQueueItem item) { EventQueueItem = item; }
public GetEntityTask(EventQueueItem item, IEntityStore entityStore) : base(item) { _entityStore = entityStore; }
public WebSubBackgroundTask(EventQueueItem item, IEntityStore entityStore, APContext context, CollectionTools collectionTools) : base(item) { _entityStore = entityStore; _context = context; _collectionTools = collectionTools; }
public WebSubBackgroundTask(EventQueueItem item, IEntityStore entityStore, DbConnection connection, CollectionTools collectionTools) : base(item) { _entityStore = entityStore; _connection = connection; _collectionTools = collectionTools; }
public DeliverToSalmonTask(EventQueueItem item, IEntityStore entityStore, AtomEntryGenerator entryGenerator, KeyService keyService) : base(item) { _entityStore = entityStore; _entryGenerator = entryGenerator; _keyService = keyService; }
public DeliverToSalmonTask(EventQueueItem item, IEntityStore entityStore, APContext context, AtomEntryGenerator entryGenerator) : base(item) { _entityStore = entityStore; _context = context; _entryGenerator = entryGenerator; }