public void PurgeAllQueues() { using (var connection = BuildConnection()) { using (var channel = connection.CreateModel()) { foreach (var queue in Queues) { queue.Purge(channel); } var others = _endpoints.Select(x => x.QueueName).Where(x => !x.IsNotEmpty()) .Where(x => Queues.All(q => q.Name != x)).ToArray(); foreach (var other in others) { channel.QueuePurge(other); } channel.Close(); } connection.Close(); } }
/// <summary> /// Remove isolated queues and restore old ones /// </summary> private void RestoreQueues() { Guard.OperationValid(_isolationLevel > 0, $"Internal Error: Called {nameof(RestoreQueues)} with no saved queues."); Guard.OperationValid(Queues.All(q => q.IsEmpty), $"Internal Error: Called {nameof(RestoreQueues)} with non-empty queues."); // Keep lock until we can remove for both methods lock (_queueLock) { log.Info("Restoring Queue State"); foreach (WorkItemQueue queue in Queues) { queue.Restore(); } _isolationLevel--; } }