public async Task ReadAsyncLong_Commands_Back() { var factory = _eventBusImpl.Factory; var connection = factory.CreateConnection(); var channel = connection.CreateModel(); var queueInfo = ListenerInfo.FromCommand(typeof(TestCommand)); string jsonResult = String.Empty; var ouOk = channel.QueueDeclare(queue: queueInfo.QueueName, durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new AsyncEventingBasicConsumer(channel); Console.WriteLine($"Read QN: {ouOk.QueueName} CC: {ouOk.ConsumerCount} MC: {ouOk.MessageCount}"); consumer.Received += ConsumerOnReceived; for (int j = 0; j < 3; j++) { var message = "Message Id: " + j + " " + RandomMessageGenerator(); _eventBusImpl.Send(new TestCommand() { AggregateId = Guid.NewGuid(), Version = j, Message = message }); channel.BasicConsume(queue: queueInfo.RoutingKey, autoAck: true, consumer: consumer); } Thread.Sleep(5000); }
private InventoryAggregate(IEventStoreRepository eventStoreRepository) : base(eventStoreRepository) { _eventBus = new EventBusImpl(); Register <ItemAddedToInventory>(Apply); Register <ItemRemovedFromInventory>(Apply); Register <ItemUpdatedInInventory>(Apply); _eventBus.RegisterAsync(ListenerInfo.FromCommand(typeof(AddItemToInventoryCommand)), AddItemToInventoryCommand); _eventBus.RegisterAsync(ListenerInfo.FromCommand(typeof(RemoveItemFromInventory)), RemoveItemFromInventoryCommand); _eventBus.RegisterAsync(ListenerInfo.FromCommand(typeof(UpdateItemInInventory)), UpdateItemInInventoryCommand); }
public void Read_Commands_Back() { _eventBusImpl.Register <TestCommand>(ListenerInfo.FromCommand(typeof(TestCommand)), Callback); for (int j = 0; j < 3; j++) { var message = "Message Id: " + j + " " + RandomMessageGenerator(); _eventBusImpl.Send(new TestCommand() { AggregateId = Guid.NewGuid(), Version = 1, Message = message }); } Thread.Sleep(5000); }
public async Task ReadAsync_Commands_Back() { for (int j = 0; j < 3; j++) { var message = "Message Id: " + j + " " + RandomMessageGenerator(); _eventBusImpl.Send(new TestCommand() { AggregateId = Guid.NewGuid(), Version = j, Message = message }); TestCommand testCommand = await _eventBusImpl.ReadAsync <TestCommand>(ListenerInfo.FromCommand(typeof(TestCommand))); Console.WriteLine($"Testcommand [{testCommand.Version} {testCommand.AggregateId}]. " + $"{testCommand.Message.Substring(0, 100)}..."); } Thread.Sleep(5000); }