public async Task Should_be_able_to_delete_an_exchange()
        {
            const string exchangeName = "delete-xcg";
            var          exchange     = await CreateExchange(exchangeName).ConfigureAwait(false);

            await managementClient.DeleteExchangeAsync(exchange).ConfigureAwait(false);
        }
        /// <summary>
        ///     Delete the given exchange
        /// </summary>
        /// <param name="source"></param>
        /// <param name="exchange"></param>
        /// <param name="cancellationToken"></param>
        public static void DeleteExchange(
            [NotNull] this IManagementClient source,
            [NotNull] Exchange exchange,
            CancellationToken cancellationToken = default
            )
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            source.DeleteExchangeAsync(exchange, cancellationToken)
            .GetAwaiter()
            .GetResult();
        }
Exemplo n.º 3
0
        public async Task DeleteUserAsync(Models.User user)
        {
            await _logConsumerService.RemoveConsumerForUserAsync(user.Username);

            _logger.LogInformation($"Log consumer for user '{user.Username}' deleted");

            await _userRepository.DeleteAsync(user.Username);

            _logger.LogInformation($"User '{user.Username}' deleted from MongoDB");

            await _elasticsearchClient.DeleteIndexAsync(user.LogIndexName);

            _logger.LogInformation($"ElasticSearch index for '{user.Username}' deleted");

            await _elasticsearchClient.DeleteUserAsync(user.Username);

            _logger.LogInformation($"ElasticSearch user '{user.Username}' deleted");

            var vhost = await _managementClient.GetVhostAsync("/");

            var errorQueue = await _managementClient.GetQueueAsync(user.ErrorQueueName, vhost);

            await _managementClient.DeleteQueueAsync(errorQueue);

            _logger.LogInformation($"RabbitMQ error queue for user '{user.Username}' deleted");

            var logQueue = await _managementClient.GetQueueAsync(user.LogQueueName, vhost);

            await _managementClient.DeleteQueueAsync(logQueue);

            _logger.LogInformation($"RabbitMQ log queue for user '{user.Username}' deleted");

            var logExchange = await _managementClient.GetExchangeAsync(user.LogExchangeName, vhost);

            await _managementClient.DeleteExchangeAsync(logExchange);

            _logger.LogInformation($"RabbitMQ exchange for user '{user.Username}' deleted");

            var rabbitUser = await _managementClient.GetUserAsync(user.Username);

            await _managementClient.DeleteUserAsync(rabbitUser);

            _logger.LogInformation($"RabbitMQ user '{user.Username}' deleted");
        }