/// <summary> /// Gets all the queued messages for the specified <paramref name="queueId"/>. /// If no queue matching the queue id is in the set, an empty list will be returned. /// </summary> /// <param name="queueId">Id of the queue from which items will be retrieved.</param> /// <returns></returns> public List <T> GetQueueItems(Guid queueId) { SharedQueue <T> queue = GetQueue(queueId); if (queue != null) { return(queue.DequeueAll()); } return(new List <T>()); }
private void Remove(SharedQueue <T> queue, bool expired) { _queues.Remove(queue); if (QueueRemoved != null) { QueueRemoved(this, new SharedQueueRemovedEventArgs <T>() { Queue = queue, QueueExpired = expired }); } }
/// <summary> /// Removes the queue matching the specified queueId. /// </summary> /// <param name="queueId"></param> /// <returns></returns> public bool RemoveQueue(Guid queueId) { lock (_queuesLock) { SharedQueue <T> queue = GetQueue(queueId); if (queue != null) { Remove(queue, false); return(true); } } return(false); }
/// <summary> /// Create a new queue for this set with the specified sub scope. /// The resulting queue scope will be a combination of the set scope and individual queue scope. /// </summary> /// <param name="subScope">The new queue's sub scope specifier.</param> /// <returns></returns> public SharedQueue <T> NewQueue(string subScope) { SharedQueue <T> queue; lock (_queuesLock) { queue = new SharedQueue <T>(subScope, this); _queues.Add(queue); } if (QueueAdded != null) { QueueAdded(this, new SharedQueueEventArgs <T>() { Queue = queue }); } return(queue); }