SALES: 1-800-867-1380

NamespaceManager.GetQueues Method (String)

Retrieves an enumerable collection of all queues in the service namespace with the specified filter. You can filter by a combination of entity name (including starts with), entity length (Gt or Lt), created, updated, and accessed time (Gt or Lt).

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

public IEnumerable<QueueDescription> GetQueues(
	string filter
)

Parameters

filter
Type: System.String
A string used to filter the queues to be retrieved.

Return Value

Type: System.Collections.Generic.IEnumerable<QueueDescription>
An IEnumerable<T> object that represents the collection of all queues in the service namespace or returns an empty collection if no queue exists.

ServiceBusConnectionString = "<your connection string>";

NamespaceManager nameSpaceManager = NamespaceManager.CreateFromConnectionString(ServiceBusConnectionString);
Console.WriteLine("List queues with more than 10 messages");
IEnumerable <QueueDescription> queueList = nameSpaceManager.GetQueues ("messageCount Gt 10");
foreach (QueueDescription qd in queueList)
{
    Console.WriteLine ("Queue name {0}; \tlength {1}", qd.Path, qd.MessageCount);
}

Console.WriteLine("\n\nList topics with no activity for more than a day");
string startTime = (DateTime.UtcNow - TimeSpan.FromDays(1)).ToString();
IEnumerable<TopicDescription> topicList = nameSpaceManager.GetTopics("startswith(path, 'q') eq true AND AccessedAt Lt '" + startTime + "'");
foreach (TopicDescription td in topicList)
{
    Console.WriteLine("Topic name {0}; \tAccessedAt {1}", td.Path, td.AccessedAt.ToString());
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft