private async Task ProcessNext() { //TODO: Allow cancellation var cmd = await _messageBusClient.Dequeue <CreateDealCommand>(); //Run slow just for fun await Task.Delay(TimeSpan.FromSeconds(2)); //Create the DealCreatedEvent in the new Deal-GUID stream. var streamName = StreamNames.DealStreamName(cmd.DealId); var eventId = Guid.NewGuid(); //Is this correct? Or should it be cmd.DealId? Or something else? var payload = cmd.ToJson(); await _eventStoreClient.SaveEvent(streamName, ExpectedVersion.NoStream, eventId, "DealCreated", payload); //We will use Projections to merge them together. }
public static async Task <T> Dequeue <T>(this IMessageBusClient client) { var payload = await client.Dequeue(typeof(T).Name); return(payload.FromJson <T>()); }