SALES: 1-800-867-1380

NamespaceManager.GetTopics Method (String)

Retrieves a collection of topics in a 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<TopicDescription> GetTopics(
	string filter


Type: System.String
The string used to filter the topics to be retrieved.

Return Value

Type: System.Collections.Generic.IEnumerable<TopicDescription>
An IEnumerable<T> object that represents the collection of topics under the current namespace, or returns an empty collection if no topic 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

© 2015 Microsoft