public async Task Handle(T command) { _log.WriteLine("Entering handler of " + command.GetType().Name); try { await _handler.Handle(command); } catch (Exception e) { _log.WriteLine(e.Message); // retry the command in case of concurrency exception if (e is ConcurrencyException) { await _handler.Handle(command); } throw; } command.Timestamp = _clock.GetCurrentInstant().ToUnixTimeMilliseconds(); await _eventStore.AppendCommand(command); }
public Task Send(object command, CommandMetadata metadata) { return(_eventStore.AppendCommand(_streamName, command, metadata)); }