Пример #1
0
        public void Send(Modelo modelo)
        {
            channel.ExchangeDeclare(exchange: Constants.TestExchange, type: ExchangeType.Direct);
            channel.QueueDeclare(queue: Constants.TestQueue, durable: false, exclusive: false, autoDelete: false, arguments: null);
            channel.QueueBind(queue: Constants.TestQueue, exchange: Constants.TestExchange, routingKey: "");

            var serializedCommand = JsonConvert.SerializeObject(modelo);

            var messageProperties = channel.CreateBasicProperties();

            messageProperties.ContentType = Constants.JsonMimeType;

            channel.BasicPublish(
                exchange: Constants.TestExchange,
                routingKey: "",
                basicProperties: messageProperties,
                body: Encoding.UTF8.GetBytes(serializedCommand));
        }