private void RabbitMQSubscription() { RabbitMQConnectionFactory rmqConn = RabbitMQConnectionFactory.RabbitMQConnectionFactoryInstance; rmqConn.CreateDirectExchange("Events", false, true); rmqConn.CreateQueue("EventsQueue", false, true, null); rmqConn.BindQueue("EventsQueue", "Events", "UserCreatedEvent"); try { var consumer = rmqConn.ConsumerEventHandlers(); consumer.Received += Consumer_Received; rmqConn.Consume("EventsQueue", true, consumer); } catch (Exception ex) { } }
public void StoreEvents(ICommand createUserCmd, object streamId, IEnumerable <object> events) { if (createUserCmd is CreateUserCommand) { StoreUsers(createUserCmd); } else if (createUserCmd is UpdateUserCommand) { } string str = JsonConvert.SerializeObject(events.First <object>()); byte[] message = Encoding.UTF8.GetBytes(str); RabbitMQConnectionFactory rmqConn = RabbitMQConnectionFactory.RabbitMQConnectionFactoryInstance; rmqConn.CreateDirectExchange("Events", false, true); rmqConn.PublishMessage("Events", "UserCreatedEvent", false, null, message, 0); // _bus.Publish(events); }