Recipe7.12.Listing the SMTP Queues on a Specific Virtual Server


Recipe 7.12. Listing the SMTP Queues on a Specific Virtual Server

Problem

You need to list the SMTP queues associated with a specific virtual server instance on your Exchange server.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (Exchange System Manager.msc).

  2. Expand the organization Administrative Groups target administrative group Servers.

  3. The right pane will display all queues on this server, including MTA, SMTP, and foreign connector queues.

  4. Click the Source field of the header to group the queues according to the component they are associated with and locate the SMTP virtual server.

Using VBScript
' This code enumerates the SMTP links and queues on an  ' Exchange Virtual Server and only works on Exchange Server 2003. ' ------ SCRIPT CONFIGURATION ------ ' host name of the Exchange server strHostname = "<ExchangeServerName>" ' e.g., red-exch02 ' The number of the SMTP virtual server instance strVSInstance = "<VSInstanceNumber>" ' e.g., 1 for the default SMTP virtual server ' ------ END CONFIGURATION --------- ' Get the Exchange Namespace WMI object Set objWMIExch =  GetObject("winmgmts://./root/MicrosoftExchangeV2") ' Get the list of Exchange_SMTPLink instances from the default virtual server ' and iterate through them. Set objLinksList = objWMIExch.ExecQuery ("Select * from Exchange_SMTPLink" &_    " Where VirtualMachine='" & strHostname &_    "' And VirtualServerName='" & strVSInstance & "'") For each objLinkInst in objLinksList    strLinkInfo = strLinkInfo & "Link Name: " &_       objLinkInst.LinkName & VbCrLF & "  Link ID: " &_       objLinkInst.LinkID & VbCrLF    ' Now, get the associated Exchange_SMTPQueue instances and iterate through    ' them.    Set objQueuesList = objWMIExch.ExecQuery ("Select * from Exchange_SMTPQueue" &_       " Where VirtualMachine='" & strHostname &_       "' And VirtualServerName='" & strVSInstance &_       "' And LinkID='" & objLinkInst.LinkID &_       "' And LinkName='" & objLinkInst.LinkName & "'" )    For each objQueueInst in objQueuesList       strLinkInfo = strLinkInfo & "  Queue Name: " &_          objQueueInst.QueueName & VbCrLF & "    Queue ID: " &_          objQueueInst.QueueID & VbCrLF    Next    strLinkInfo = strLinkInfo & VbCrLF Next Wscript.Echo strLinkInfo

Discussion

To get a good understanding of traffic flow through Exchange, you need to understand queues and links. Each Exchange SMTP virtual server (or X.400 stack for the MTA transport) has its own set of queues, which are a set of folders on an NTFS partition. Each queue holds messages destined for a single DNS domain; messages addressed to recipients in the 3sharp.com and redmond.3sharp.com domains are placed in two different queues.

Links are virtual memory structures that represent the next system a message must be sent to. Each link is associated with zero or more queues. While it may sound odd that links can have no queues, not all links are transient in an Exchange organization; routing group connectors and smart hosts provide dedicated links to next-hop systems and the links to them exist even when there is no traffic to route through them. Conversely, a link can have more than one associated queue, such as when the remote server is published in DNS as the MX host for multiple domains.

Tracking links and queues through the Exchange System Manager Queue Viewer can be somewhat confusing; what ESM calls queues are actually links. It uses the Queue API to provide a unified management interface for the links and queues on the server, presenting them without distinguishing precisely what is a link and what is a queue. WMI always makes the difference explicit. There are a default set of SMTP system queues and links that are always present. They are shown in Table 7-3 along with their corresponding WMI properties and ESM queue names.

Table 7-3. Exchange SMTP system links and queues

WMI QueueName property

WMI LinkName property

ESM queue name

DeferredDeliveryQueue

DeferredDeliveryQueue

Messages queued for deferred delivery

FailedMessageQueue

FailedMessageQueue

Failed message retry queue

LocalAsyncQueue

<local primary domain name>

Local delivery

PostDSNGenerationQueue

PostDSNGenerationQueue

DSN messages pending submission

PreCatQueue

PreCatQueue

Messages awaiting directory lookup

PreRoutingQueue

PreRoutingQueue

Messages waiting to be routed

PreSubmissionQueue

PreSubmissionQueue

Messages pending submission


To get an accurate view of the queues and links, you need to use WMI scripting. Exchange 2000 provides two classes through the ExchangeQueueProvider provider; these classes, ExchangeLink and ExchangeQueue, provide read-only access to the status of all links and queues on the server. Exchange Server 2003 supplies additional WMI providers and classes that allow you to easily choose between SMTP and X.400 queues and links and manage them. These new classes are shown in Table 7-4.

Table 7-4. Additional WMI queue and link classes provided by Exchange Server 2003

Classes

Description

Exchange_LinkExchange_Queue

Instead of extending the existing classes, these two classes provide the base properties for the new classes.

Exchange_SMTPLinkExchange_X400Link

These classes inherit the properties from the Exchange_Link class and provide transport-specific methods for controlling the state of the link.

Exchange_SMTPQueueExchange_X400Queue

These classes inherit the properties from the Exchange_Queue class and provide transport-specific properties for the queues.


For day-to-day management and monitoring of the SMTP queues, you will only need to deal with the Exchange_SMTPLink and Exchange_SMTPQueue classes. As demonstrated by the script above, using these classes together to obtain queue information is not difficult. A simple WMI Query Language (WQL) query, constrained by the physical server name and (if desired) virtual server instance, enumerates your existing links. You can then pull the LinkID and LinkName properties to use as a constraint against a second WQL query for the associated queues.

See Also

MSDN: Exchange_Link, MSDN: Exchange_Queue, MSDN: Exchange_SMTPLink, MSDN: Exchange_SMTPQueue, MSDN: Exchange_X400Link, MSDN: Exchange_X400Queue, Recipe 7.13 for listing messages in a queue, and Recipe 7.14 for deleting messages from a queue



Exchange Server Cookbook
Exchange Server Cookbook: For Exchange Server 2003 and Exchange 2000 Server
ISBN: 0596007175
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net