pardahlman / RawRabbit

A modern .NET framework for communication over RabbitMq
MIT License
746 stars 144 forks source link

E2E bindings? #359

Open vzwick opened 6 years ago

vzwick commented 6 years ago

Hey!

Does RawRabbit currently support E2E bindings? I can't seem to find anything relevant beside BindQueueAsync which doesn't seem to work with E2E.

houseofcat commented 6 years ago

Just browsing real quick I don't really see an ExchangeBindMiddleware but you could add a class that inherits from Middleware and roll your own. Use QueueBindMiddleware as an example.

You would then modify your own Action<IPipeBuilder>() pipe.

At the bottom you would add .Use<ExchangeBindMiddleware>().

private static readonly Action<IPipeBuilder> CreateExchangeAndQueueAndBinding = pipe => pipe
            .Use<ConsumeConfigurationMiddleware>()
            .Use<ExchangeDeclareMiddleware>(new ExchangeDeclareOptions() { ExchangeFunc = context =>
             {
                 var consume = context.GetConsumeConfiguration();
                 var cfg = context.GetClientConfiguration().Exchange;
                 return new ExchangeDeclaration
                 {
                     Arguments = new Dictionary<string, object>(),
                     ExchangeType = cfg.Type.ToString().ToLower(),
                     Durable = cfg.Durable,
                     AutoDelete = cfg.AutoDelete,
                     Name = consume.ExchangeName
                 };
             } })
            .Use<QueueDeclareMiddleware>(new QueueDeclareOptions() { QueueDeclarationFunc = context =>
            {
                var consume = context.GetConsumeConfiguration();
                var cfg = context.GetClientConfiguration().Queue;
                return new QueueDeclaration
                {
                    Arguments = new Dictionary<string, object>(),
                    Exclusive = cfg.Exclusive,
                    Durable = cfg.Durable,
                    AutoDelete = cfg.AutoDelete,
                    Name = consume.QueueName
                };
            } })
            .Use<QueueBindMiddleware>();