public static Outbox Restore(string requestId, long aggregateId, bool isStored, bool isDispatched, object response, IEnumerable <object> commands, IEnumerable <object> events) { var instance = new Outbox(requestId, aggregateId, isStored, isDispatched) { Response = response }; if (commands != null) { instance._commands.AddRange(commands); } if (events != null) { instance._events.AddRange(events); } return(instance); }
public async Task EnsureDispatched(Outbox outbox, IOutboxDispatcher dispatcher) { if (outbox.IsDispatched) { return; } foreach (var command in outbox.Commands) { await dispatcher.Send(command); } foreach (var evt in outbox.Events) { await dispatcher.Publish(evt); } await _repository.Save(outbox, OutboxPersistingReason.Dispatching); outbox.IsDispatched = true; }
public static Outbox Restore(string idempotencyId, bool isDispatched, object response, IEnumerable <object> commands, IEnumerable <object> events) { var instance = new Outbox(idempotencyId, isClosed: true, isDispatched) { Response = response }; if (commands != null) { instance._commands.AddRange(commands); } if (events != null) { instance._events.AddRange(events); } return(instance); }
public async Task <Outbox> Open(string idempotencyId) { var existingOutbox = await _repository.GetOrDefault(idempotencyId); return(existingOutbox ?? Outbox.Open(idempotencyId)); }
public Task Save(Outbox outbox, OutboxPersistingReason reason) { throw new InvalidOperationException("Outbox repository is not configured. To use outbox, you need to configure repository in service.AddOutbox(c => {...})"); }
public async Task Store(Outbox outbox) { await _repository.Save(outbox, OutboxPersistingReason.Storing); outbox.IsStored = true; }