/// <summary> /// If auto destroy is enabled, checks and removes queue if it should be removed /// </summary> internal async Task CheckAutoDestroy() { if (IsDestroyed || Options.AutoDestroy == QueueDestroy.Disabled) { return; } switch (Options.AutoDestroy) { case QueueDestroy.NoConsumers: if (_clients.Count == 0) { await Server.RemoveQueue(this); } break; case QueueDestroy.NoMessages: if (MessagesList.Count == 0 && PriorityMessagesList.Count == 0 && !TimeKeeper.HasPendingDelivery()) { await Server.RemoveQueue(this); } break; case QueueDestroy.Empty: if (_clients.Count == 0 && MessagesList.Count == 0 && PriorityMessagesList.Count == 0 && !TimeKeeper.HasPendingDelivery()) { await Server.RemoveQueue(this); } break; } }