Exemple #1
0
        public Task Subscribe(Type eventType, ContextBag context)
        {
            using (var connection = connectionFactory.CreateAdministrationConnection())
                using (var channel = connection.CreateModel())
                {
                    routingTopology.SetupSubscription(channel, eventType, localQueue);
                }

            return(Task.CompletedTask);
        }
Exemple #2
0
 public Task SubscribeAll(MessageMetadata[] eventTypes, ContextBag context, CancellationToken cancellationToken = default)
 {
     using (var connection = connectionFactory.CreateAdministrationConnection())
         using (var channel = connection.CreateModel())
         {
             foreach (var eventType in eventTypes)
             {
                 routingTopology.SetupSubscription(channel, eventType, localQueue);
             }
         }
     return(Task.CompletedTask);
 }
        public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity)
        {
            using (var connection = connectionFactory.CreateAdministrationConnection())
                using (var channel = connection.CreateModel())
                {
                    DelayInfrastructure.Build(channel);

                    routingTopology.Initialize(channel, queueBindings.ReceivingAddresses, queueBindings.SendingAddresses);

                    foreach (var receivingAddress in queueBindings.ReceivingAddresses)
                    {
                        routingTopology.BindToDelayInfrastructure(channel, receivingAddress, DelayInfrastructure.DeliveryExchange, DelayInfrastructure.BindingKey(receivingAddress));
                    }
                }

            return(TaskEx.CompletedTask);
        }
        internal void SetupInfrastructure(string[] sendingQueues)
        {
            using (var connection = connectionFactory.CreateAdministrationConnection())
                using (var channel = connection.CreateModel())
                {
                    DelayInfrastructure.Build(channel);

                    var receivingQueues = Receivers.Select(r => r.Value.ReceiveAddress).ToArray();

                    routingTopology.Initialize(channel, receivingQueues, sendingQueues);

                    foreach (string receivingAddress in receivingQueues)
                    {
                        routingTopology.BindToDelayInfrastructure(channel, receivingAddress, DelayInfrastructure.DeliveryExchange, DelayInfrastructure.BindingKey(receivingAddress));
                    }
                }
        }
        public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity)
        {
            using (var connection = connectionFactory.CreateAdministrationConnection())
                using (var channel = connection.CreateModel())
                {
                    foreach (var receivingAddress in queueBindings.ReceivingAddresses)
                    {
                        CreateQueueIfNecessary(channel, receivingAddress);
                    }

                    foreach (var sendingAddress in queueBindings.SendingAddresses)
                    {
                        CreateQueueIfNecessary(channel, sendingAddress);
                    }
                }

            return(TaskEx.CompletedTask);
        }
Exemple #6
0
        public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity)
        {
            using (var connection = connectionFactory.CreateAdministrationConnection())
                using (var channel = connection.CreateModel())
                {
                    DelayInfrastructure.Build(channel);

                    var queueDeclaringTopology = routingTopology as IDeclareQueues;

                    if (queueDeclaringTopology != null)
                    {
                        queueDeclaringTopology.DeclareAndInitialize(channel, queueBindings.ReceivingAddresses, queueBindings.SendingAddresses);
                    }
                    else
                    {
                        foreach (var receivingAddress in queueBindings.ReceivingAddresses)
                        {
                            CreateQueueIfNecessary(channel, receivingAddress);
                        }

                        foreach (var sendingAddress in queueBindings.SendingAddresses)
                        {
                            CreateQueueIfNecessary(channel, sendingAddress);
                        }
                    }

                    var delayTopology = routingTopology as ISupportDelayedDelivery;

                    if (delayTopology != null)
                    {
                        foreach (var receivingAddress in queueBindings.ReceivingAddresses)
                        {
                            delayTopology.BindToDelayInfrastructure(channel, receivingAddress, DelayInfrastructure.DeliveryExchange, DelayInfrastructure.BindingKey(receivingAddress));
                        }
                    }
                }

            return(TaskEx.CompletedTask);
        }