public void ListenForRegisterOrderCommand() { channel.QueueDeclare( queue: RabbitMqConstants.GetRegisterOrderQueue("Registration"), durable: false, exclusive: false, autoDelete: false, arguments: null); channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false); var consumer = new RegisteredOrderCommandConsumer(this); channel.BasicConsume( queue: RabbitMqConstants.GetRegisterOrderQueue("Registration"), noAck: false, consumer: consumer); }
public void SendRegisterOrderCommand(IRegisterOrder command) { channel.ExchangeDeclare( exchange: RabbitMqConstants.GetRegisterOrderExchange(), type: ExchangeType.Direct); var serializedCommand = JsonConvert.SerializeObject(command); var messageProperties = channel.CreateBasicProperties(); messageProperties.ContentType = RabbitMqConstants.JsonMimeType; channel.BasicPublish( exchange: "", routingKey: RabbitMqConstants.GetRegisterOrderQueue("Registration"), basicProperties: messageProperties, body: Encoding.UTF8.GetBytes(serializedCommand)); }