コード例 #1
0
        public void CreateExchangeAndQueue()
        {
            var factory = new ConnectionFactory
            {
                Uri = new Uri(TestUri)
            };

            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare("exchange", type: "fanout", durable: false, autoDelete: false);
                    channel.QueueDeclare("queue", durable: false, exclusive: false, autoDelete: false);
                    channel.QueueBind("queue", "exchange", routingKey: "");
                }
            }

            _inputParameters = new WriteInputParams
            {
                Data           = new byte[] { 0, 1, 2 },
                HostName       = TestHost,
                RoutingKey     = "queue",
                QueueName      = "queue",
                ConnectWithURI = false,
                Create         = false,
                Durable        = false
            };



            _inputParametersString = new WriteInputParamsString
            {
                Data           = "test message",
                HostName       = TestHost,
                RoutingKey     = "queue",
                QueueName      = "queue",
                ConnectWithURI = false,
                Create         = false,
                Durable        = false
            };

            _outputReadParams = new ReadInputParams
            {
                HostName         = TestHost,
                QueueName        = "queue",
                AutoAck          = ReadAckType.AutoAck,
                ReadMessageCount = 1,
                ConnectWithURI   = false
            };
        }
コード例 #2
0
        public void CreateExchangeAndQueue()
        {
            var factory = new ConnectionFactory
            {
                Uri = new Uri(TestUri)
            };

            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare("exchange", type: "fanout", durable: false, autoDelete: false);
                    channel.QueueDeclare("queue", durable: false, exclusive: false, autoDelete: false);
                    channel.QueueBind("queue", "exchange", routingKey: "");
                }
            }

            _inputParameters = new WriteInputParams
            {
                Data           = new byte[] { 0, 1, 2 },
                HostName       = TestHost,
                RoutingKey     = "queue",
                QueueName      = "queue",
                ConnectWithURI = false,
                Create         = false,
                Durable        = false,
                Headers        = null
            };



            _inputParametersString = new WriteInputParamsString
            {
                Data           = "test message",
                HostName       = TestHost,
                RoutingKey     = "queue",
                QueueName      = "queue",
                ConnectWithURI = false,
                Create         = false,
                Durable        = false,
                Headers        = new Header[]
                {
                    new Header {
                        Name = "X-AppId", Value = "application id"
                    },
                    new Header {
                        Name = "X-ClusterId", Value = "cluster id"
                    },
                    new Header {
                        Name = "Content-Type", Value = "content type"
                    },
                    new Header {
                        Name = "Content-Encoding", Value = "content encoding"
                    },
                    new Header {
                        Name = "X-CorrelationId", Value = "correlation id"
                    },
                    new Header {
                        Name = "X-Expiration", Value = "100"
                    },
                    new Header {
                        Name = "X-MessageId", Value = "message id"
                    },
                    new Header {
                        Name = "Custom-Header", Value = "custom header"
                    }
                }
            };

            _outputReadParams = new ReadInputParams
            {
                HostName         = TestHost,
                QueueName        = "queue",
                AutoAck          = ReadAckType.AutoAck,
                ReadMessageCount = 1,
                ConnectWithURI   = false
            };
        }