Section 13.2. The Microsoft Message Queue


13.2. The Microsoft Message Queue

The Microsoft Message Queuing Service (MSMQ) provides you, as the system administrator, with a way to collect messaging transactions from various messaging-aware applications and queue them until applications are ready to process them. Messages, in this case, aren't like email messages between human users, but are functional messages or data exchanged between applications.

What is MSMQ used for? The MSMQ services come into play when one application wants to exchange a message with another application, but that particular application isn't responding. When one person needs to communicate fairly quickly with another person, he typically uses a phone. If the person he is trying to reach isn't at his desk, and there is no voice mail or answering machine, the original caller needs to continue trying to reach the personwhich can turn into a big waste of time. However, if he can leave a voice mail message in the other person's message "queue," the caller can go on about his other work and wait for the other person to deal with the message and take any appropriate action. MSMQ works the same way, providing a storage-and-retrieval service for applications that are available to accept messages sent to them. This allows sending applications to get on with their other processes without dedicating resources to continuing attempts to transmit messages to unavailable applications.

The queuethe holding bin for these messagescomes in different types and performs different functions:

  • Administration queues are established by the transmitting application and only serve to acknowledge sent messages.

  • Public queues are available to any computer within your organization, and are published within Active Directory and are replicated among the domain controllers in your domain or forest.

  • Private queues are specific to only a few applications that have specific awareness of the existence of those queuesthey are not published in Active Directory.

  • Dead-letter queues hold messages that can't be delivered.

  • Response queues hold messages sent in response to previous messages, destined for the original sender.

  • Report queues detail the route taken by a message to its destination.

  • System queues combine other queues to orchestrate communication between the system and application.

  • Journal queues copy messages to make sure they are delivered correctly.

The messages stored within these queues consist of a header, which contains the message identifier and other specific properties, and the body, which is the meat of the message and can be encrypted if it contains sensitive information. Messages cannot exceed 4MB in size. There are four types of messages:

  • Normal messages are typical exchanges of information between applications, and can come from public, private, journal, or dead-letter queues.

  • Report messages customarily are test messages designed to determine what routing occurs for messages.

  • Response messages are confirmations from the destination applications, such as responses to normal ping traffic on TCP/IP.

  • Acknowledgement messages are like read receipts and acknowledge the receipt of messages on the part of the destination application.

13.2.1. Communications with MSMQ

The basis of communications for MSMQ is the Active Directory site; thus, all message exchange between queues and applications is done within the context of your organization's Active Directory structure. MSMQ is a very chatty service and it uses a lot of network bandwidth, so make sure you place at least one MSMQ server in each Active Directory site or subnet to mitigate that effect. For traffic between sites, MSMQ uses routing links, which use the TCP/IP protocol to pass traffic to and from hosts.

Where direct connections cannot be established, the MSMQ software routes messages according to rules dictating how messages should be transmitted. Messages that are routed move from station to stationor "hop" to "hop," as it is formally knownuntil the destination is reached. MSMQ attempts to route messages along the least costly route, where the cost is derived from the available bandwidth divided by the actual currency cost of the connection. (This requires outside math on your part.) You specify the cost of the link to MSMQ, and it takes that into account when routing messages between MSMQ servers.

13.2.2. MSMQ Administration

Although much MSMQ detail is beyond the scope of this book, a lot of administrators find themselves administering MSMQ at least in part. With that in mind, the next section details some very common administrative tasks you can perform with the MSMQ. For a more detailed approach to MSMQ development and administration, consult a book or online resource dedicated to the topic.

13.2.2.1 Installing MSMQ

You can easily install MSMQ from the Add/Remove Programs tool within the Control Panel. Open the tool, and then select Add/Remove Windows Components from the left pane. Select Application Server, and then click the Details button. Finally, check the checkbox next to Message Queuing, and click OK and then Next to install the components.

Some tips for best performance of MSMQ servers and links:

  • If you have multiple Active Directory sites in your forest, try to install MSMQ on at least one server in every site. This way, messages will be more reliably delivered to their destinations between sites, and client broadcast requests will be acknowledged more efficiently.

  • Try to install MSMQ on a Windows domain controller that is functioning as a global catalog server. This improves performance. In fact, installing MSMQ on multiple domain controllers will improve performance further.

  • However, if you choose to install MSMQ on a domain controller, avoid installing it with routing enabled.

MSMQ automatically will take on the identity of the site into which it's installed.


13.2.2.2 Finding an MSMQ server

To find a machine that is running the MSMQ software, open Active Directory Users and Computers, and then do the following:

  1. From the View menu, select Users, Groups, and Computers as containers.

  2. Again from the View menu, select Advanced Features.

  3. In the left pane, select the relevant domain, and then expand the node and select Computers. Alternatively, select Domain Controllers if you have MSMQ installed on your domain controllers, as described earlier.

  4. In the right pane, click each computer. Look for the MSMQ folder on each.

13.2.2.3 Setting a maximum message size

You might want to set a maximum message size for a particular system, given disk space restraints or bandwidth concerns. To do so, take these steps:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. In the left pane, right-click MSMQ and choose Properties from the context menu.

  5. Navigate to the General tab.

  6. Under Storage limits, check the Limit message storage to (KB) option.

  7. Enter a value, in kilobytes, that represents the maximum message size this system will accept.

13.2.2.4 Enabling and disabling journals

Recall that journals are simply copies of messages to track their history. To enable or disable journals, follow these steps:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again, from the View menu, select Advanced Features.

  4. In the left pane, right-click the appropriate MSMQ queue and choose Properties from the context menu.

  5. Navigate to the General tab.

  6. Under the Journal section, check the Enable box.

13.2.2.5 Limiting journal size

Like the maximum message size, you might want to constrain the amount of disk space available for journaling. To do so, follow these steps:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. In the left pane, right-click MSMQ and choose Properties from the context menu.

  5. Navigate to the General tab.

  6. Under Storage limits, check the Limit journal storage to (KB) option.

  7. Enter a value, in kilobytes, that represents the maximum journal size this system will allow.

13.2.2.6 Finding a queue

To find an MSMQ queue within your organization, do the following:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. In the left pane, right-click Computers, and select Find from the context menu.

  5. Navigate to the Find MSMQ Queue tab.

  6. Enter your search criteria in the Label or Type ID box, and then click Find Now.

13.2.2.7 Deleting a queue

At certain times, you might want to completely terminate a queue. To do so, follow these steps:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. Right-click the appropriate queue in the left pane, and select Delete.

  5. Confirm your choice by clicking Yes at the prompt.

13.2.2.8 Viewing the properties of a message

To view the properties of a message, do the following:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. In the left pane, find the appropriate queue and select it.

  5. Then, in the right pane, right-click the appropriate message and select Properties.

13.2.2.9 Deleting all messages

You might want to clear a queue of messages. To purge all messages in a queue, do the following:

  1. Open Active Directory Users and Computers.

  2. From the View menu, select Users, Groups, and Computers as containers.

  3. Again from the View menu, select Advanced Features.

  4. In the left pane, find the appropriate queue and select it.

  5. Then, right-click Queue messages, and from the All tasks menu, select Purge.

  6. Confirm your choice by clicking Yes at the prompt.

13.2.2.10 Creating routing links

Routing links are used to send messages between separate sites. Messages are routed through these links according to the cost of the link, a numeric identifier indicating the preference of the administrator as to how often a particular routing link is used. The lower the cost, the more often MSMQ will pass traffic over that routing link.

Only users in the Enterprise Admins group can create or modify links if there are multiple domains in your organization.

To create routing links, follow these steps:

  1. Open Active Directory Sites and Services.

  2. From the View menu, select Show Services Node.

  3. In the console tree, right-click MsmqServices.

  4. Select MSMQ Routing Link from the New menu.

  5. In the screen that appears, select the site in the Site 1 list from which messages to be passed over this link should originate. In the Site 2 list, pick the destination site.

  6. Enter the cost of the routing link in the Routing link cost box. Remember: the lower the cost, the more often the link will be used. Enter 0 to disable to link.

  7. Click OK to finish.

There are a couple of issues to remember when creating routing links:

  • Try to connect individual sites to each other using routing links and site gates. You should create a routing link to every new Active Directory site that is created.

  • Tell MSMQ clients to use in-routing and out-routing servers for message routing to pass messages within a particular site.

13.2.2.11 Configuring routing links

Site gates represent individual MSMQ servers that service a routing link between sites. You might have occasion to add or remove servers that take care of a linkperhaps due to administrative maintenance or to decommission a particular machine.

To change the servers that coordinate the site link, follow these steps:

  1. Open Active Directory Sites and Services.

  2. From the View menu, select Show Services Node.

  3. In the console tree, click MsmqServices.

  4. In the right pane, right-click the appropriate routing link and select Properties from the pop-up context menu.

  5. Navigate to the Site Gates tab.

  6. To add a server to the link, select a server from the list in Site Servers and click the Add button. To remove a server presently servicing the link, select a server from the list in Site Gates and click the Remove button.

  7. Click OK to finish.

You also might need to adjust the cost value you have assigned to a routing link for various reasons. To do so, follow these steps:

  1. Open Active Directory Sites and Services.

  2. From the View menu, select Show Services Node.

  3. In the console tree, click MsmqServices.

  4. In the right pane, right-click the appropriate routing link and select Properties from the pop-up context menu.

  5. Navigate to the General tab.

  6. In the Link cost box, specify a new cost.

  7. Click OK to finish.

13.2.2.12 Creating foreign sites

Foreign sites are groups of computers that communicate with MSMQ servers that are apart from the current network. Much like Active Directory sites, which you learned about in Chapter 5, MSMQ sites are used to delineate the geographical positions of remote networks.

Here's how to create a new foreign site:

  1. Open Active Directory Sites and Services.

  2. From the View menu, select Show Services Node.

  3. In the console tree, right-click MsmqServices.

  4. From the context menu, click New Foreign Site.

  5. Enter the name for the new site on the screen that appears, and click OK to finish.

Now you need to add foreign computers to the new foreign site. Follow the preceding steps, except in step 4, select New Foreign Computer. In the Name box of the resulting screen, enter the name of the foreign computer, and then select the foreign site to which that machine should belong. Click OK when you've finished the process.

13.2.3. Issues with MSMQ and Firewalls

MSMQ has certain requirements when communicating with machines on either side of a firewall. It is recommended that if MSMQ computers that reside externally to your firewall need to access your organization's Active Directory, you should configure a VPN for that communication that uses the point-to-point tunneling protocol (PPTP). VPNs are covered in detail in Chapter 11.

If you just need MSMQ traffic to be passed through your firewall without access to the Active Directory, remote clients sending messages internally require only TCP port 1801 to be open on your firewall. Computers in this scenario cannot access Active Directory, nor can their messages be routed; hence, the destination computer must be directly reachable on the other side of the firewall.

13.2.4. More Resources

If administering MSMQ is a large part of your job, you might want to consult the following resources for more information:

  • The MSMQ online documentation, which you can find at http://windows.microsoft.com/windows2000/en/server/help/default.asp?url=/windows2000/en/server/help/sag_msmqconcepts3_3.htm

  • The book Designing Applications with MSMQ: Message Queuing for Developers (Addison Wesley Professional).



    Learning Windows Server 2003
    Learning Windows Server 2003
    ISBN: 0596101236
    EAN: 2147483647
    Year: 2003
    Pages: 149

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