Chinchilla.Topologies.Model.Topology.DefineExchange C# (CSharp) Method

DefineExchange() public method

public DefineExchange ( string name, ExchangeType exchangeType, Durability durablility = Durability.Durable, bool isAutoDelete = false ) : IExchange
name string
exchangeType ExchangeType
durablility Durability
isAutoDelete bool
return IExchange
        public IExchange DefineExchange(
            string name,
            ExchangeType exchangeType,
            Durability durablility = Durability.Durable,
            bool isAutoDelete = false)
        {
            var exchange = new Exchange(name, exchangeType)
            {
                IsAutoDelete = isAutoDelete,
                Durability = durablility
            };

            exchanges.Add(exchange);
            return exchange;
        }

Usage Example

        public void ShouldVisitTopologyWithQueueBoundToExchange()
        {
            var factory = new DefaultConnectionFactory();
            using (var connection = factory.Create(new Uri("amqp://localhost/integration")))
            {
                var model = connection.CreateModel();

                var topology = new Topology();
                var e1 = topology.DefineExchange("exchange1", ExchangeType.Topic);
                var q1 = topology.DefineQueue("queue");

                q1.BindTo(e1);

                topology.Visit(new TopologyBuilder(model));

                var exchanges = admin.Exchanges(IntegrationVHost);
                Assert.That(exchanges.Any(e => e.Name == e1.Name));

                var queues = admin.Queues(IntegrationVHost);
                Assert.That(queues.Any(e => e.Name == q1.Name));
            }
        }