Пример #1
0
        /// <summary>
        /// Provision service bus queues
        /// </summary>
        /// <param name="serviceBusConnectionString">Service bus connection string</param>
        /// <returns>Provision task</returns>
        private static async Task ProvisionServiceBusQueues(string serviceBusConnectionString)
        {
            Console.WriteLine("Creating service bus queues...");
            foreach (QueueIdentifier queueIdentifier in Enum.GetValues(typeof(QueueIdentifier)))
            {
                if (!QueueDescriptorProvider.Queues.ContainsKey(queueIdentifier))
                {
                    Console.WriteLine("  " + queueIdentifier.ToString() + " - Descriptor not found");
                    continue;
                }

                QueueDescriptor queueDescriptor = QueueDescriptorProvider.Queues[queueIdentifier];
                ServiceBus      serviceBus      = new ServiceBus(serviceBusConnectionString);
                await serviceBus.CreateQueueAsync(queueDescriptor.QueueName);

                Console.WriteLine("  " + queueIdentifier.ToString() + " - Queue Provisioned");
            }
        }
Пример #2
0
        /// <summary>
        /// Abstração do canal de Comunicação com o RabbitMQ
        /// </summary>
        /// <param name="services">Provedor de serviços</param>
        /// <param name="model">RabbitMq model</param>
        /// <param name="descriptor">Descrição da fila</param>
        /// <param name="serializer">Encapsulamento do serializador</param>
        /// <param name="blockingCollection">Bloqueio para utilização de RPC</param>
        /// <param name="config">Configurações do framework</param>
        protected Channel(
            IServiceProvider services,
            IModel model,
            QueueDescriptor descriptor,
            Serializer serializer,
            BlockingCollection <BasicDeliverEventArgs> blockingCollection,
            RabbitMqConfiguration config)
        {
            _services  = services;
            Descriptor = descriptor;
            var loggerFactory = (ILoggerFactory)_services.GetService(typeof(ILoggerFactory));

            _blockingCollection = blockingCollection;
            _config             = config;
            _model                 = model;
            _serializer            = serializer;
            _consumer              = new EventingBasicConsumer(_model);
            _eventingBasicConsumer = new EventingBasicConsumer(model);
            _logger                = loggerFactory?.CreateLogger <Channel>();
        }
Пример #3
0
        /// <summary>
        /// Delete all the service bus queues
        /// </summary>
        /// <param name="serviceBusConnectionString">connection string to service bus</param>
        /// <returns>delete task</returns>
        private static async Task DeleteServiceBusQueues(string serviceBusConnectionString)
        {
            // Delete service bus queues.
            // TODO: Investigate the delete function for service bus queue. We've had problems with it in the past.
            Console.WriteLine("Deleting service bus queues...");
            foreach (QueueIdentifier queueIdentifier in Enum.GetValues(typeof(QueueIdentifier)))
            {
                if (!QueueDescriptorProvider.Queues.ContainsKey(queueIdentifier))
                {
                    Console.WriteLine("  " + queueIdentifier.ToString() + " - Descriptor not found");
                    continue;
                }

                QueueDescriptor queueDescriptor = QueueDescriptorProvider.Queues[queueIdentifier];
                ServiceBus      serviceBus      = new ServiceBus(serviceBusConnectionString);
                await serviceBus.DeleteQueueAsync(queueDescriptor.QueueName);

                Console.WriteLine("  " + queueIdentifier.ToString() + " - Queue Deleted");
            }
        }