コード例 #1
0
        protected internal override void Apply(IManagementClient managementClient)
        {
            var destinationName = ToQueueDeclared ? ToQueue : ToExchange;

            _log.Info($"Declaring binding from '{FromExchange}' to '{destinationName}'");
            _log.Info($"    RoutingKey = {RoutingKey}");

            var virtualHost = managementClient.GetVhost(VirtualHost);
            var exchange    = managementClient.GetExchange(FromExchange, virtualHost);
            var info        = new BindingInfo(RoutingKey);

            if (ToQueueDeclared)
            {
                var toQueue = managementClient.GetQueue(ToQueue, virtualHost);
                managementClient.CreateBinding(exchange, toQueue, info);
            }

            if (ToExchangeDeclared)
            {
                var toExchange = managementClient.GetExchange(ToExchange, virtualHost);
                managementClient.CreateBinding(exchange, toExchange, info);
            }

            _log.Info($"Finished declaring binding from '{FromExchange}' to '{destinationName}'");
        }
コード例 #2
0
        public void Should_create_binding()
        {
            var vhost    = managementClient.GetVhost(vhostName);
            var queue    = managementClient.GetQueue(testQueue, vhost);
            var exchange = managementClient.GetExchange(testExchange, vhost);

            var bindingInfo = new BindingInfo(testQueue);

            managementClient.CreateBinding(exchange, queue, bindingInfo);
        }
コード例 #3
0
        public async Task Should_get_all_bindings_for_which_the_exchange_is_the_source()
        {
            var sourceXchange = await CreateExchange("sourceXcg").ConfigureAwait(false);

            var destionationXchange = await CreateExchange("destinationXcg").ConfigureAwait(false);

            var bindingInfo = new BindingInfo("#");
            await managementClient.CreateBinding(sourceXchange, destionationXchange, bindingInfo).ConfigureAwait(false);

            Assert.NotEmpty((await managementClient.GetBindingsWithSourceAsync(sourceXchange).ConfigureAwait(false)).ToList());
        }