Example #1
0
        public void ByteConvertorToBytesTest()
        {
            var input = new List <int>()
            {
                1, 2, 3
            };

            var res = ByteConvertor.ToBytes <byte>(input);

            Assert.IsTrue(res.Length == 3);
        }
Example #2
0
        /// <summary>
        /// Publish message
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        public void Send <T>(Send <T> action)
        {
            using (var connection = _connectionFactory.CreateConnection(action.Host))
                using (var channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare(exchange: action.ExhangeName, type: ExchangeType.Fanout);

                    var body = ByteConvertor.ObjectToByteArray <T>(action.Message);

                    channel.BasicPublish(exchange: action.ExhangeName,
                                         routingKey: "",
                                         basicProperties: null,
                                         body: body);
                }
        }
Example #3
0
        /// <summary>
        /// Publish message.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        public void Send <T>(Send <T> action)
        {
            using (var connection = _connectionFactory.CreateConnection(action.Host))
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: action.QueueName,
                                         durable: true,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    var body = ByteConvertor.ObjectToByteArray <T>(action.Message);

                    channel.BasicPublish(exchange: "",
                                         routingKey: action.RouteKey,
                                         basicProperties: null,
                                         body: body);
                }
        }