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"); }
/// <summary> /// Delete the given queue /// </summary> /// <param name="source"></param> /// <param name="queue"></param> /// <param name="cancellationToken"></param> public static void DeleteQueue( [NotNull] this IManagementClient source, [NotNull] Queue queue, CancellationToken cancellationToken = default ) { if (source == null) { throw new ArgumentNullException(nameof(source)); } source.DeleteQueueAsync(queue, cancellationToken) .GetAwaiter() .GetResult(); }
public async Task Should_be_able_to_delete_a_queue() { var queue = await CreateTestQueue(testQueue).ConfigureAwait(false); await managementClient.DeleteQueueAsync(queue).ConfigureAwait(false); }