15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Programming Message Queuing ❘ 1363<br />

message queue Properties<br />

After a queue is created, you can modify the<br />

queue ’ s properties with the Computer Management<br />

snap - in by selecting the queue in the tree pane<br />

<strong>and</strong> selecting the Action Properties menu (see<br />

Figure 46 - 6).<br />

Several options can be confi gured:<br />

➤<br />

➤<br />

The label is the name of the queue that can be used<br />

to search for the queue.<br />

The type ID, which is by default, set to<br />

{00000000– 0000 – 0000 – 0000 – 000000000000}<br />

to map multiple queues to a single category or type.<br />

Report queues use a specifi c type ID, as discussed<br />

earlier. A type ID is a universal unique ID (UUID)<br />

or GUID.<br />

figure 46-6<br />

Custom type identifi ers can be created with the uuidgen.exe or guidgen.exe utilities.<br />

uuidgen.exe is a comm<strong>and</strong>-line utility used to create unique IDs, <strong>and</strong> guidgen.exe is<br />

a graphical version to create UUIDs.<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

The maximum size of all messages of a queue can be limited to avoid fi lling up the disk.<br />

When checked, the Authenticated option allows only authenticated users to write <strong>and</strong> read messages<br />

to <strong>and</strong> from the queue.<br />

With the Privacy Level option, the content of the message can be encrypted. The possible values to<br />

set are None, Optional, or Body. None means that no encrypted messages are accepted, Body accepts<br />

only encrypted messages, <strong>and</strong> the default Optional value accepts both.<br />

Target journaling can be confi gured with the Journal settings. With this option, copies of the<br />

messages received are stored in the journal. The maximum size of disk space that is occupied can be<br />

confi gured for the journal messages of a queue. When the maximum size is reached, target journaling<br />

is ceased.<br />

With the confi guration option Multicast, you can defi ne a multicast IP address for the queue. The<br />

same multicast IP address can be used with different nodes in the network, so that a message sent to a<br />

single address is received with multiple queues.<br />

Programming message queuing<br />

Now that you underst<strong>and</strong> the architecture of Message Queuing, you can look into the programming. In the<br />

next sections, you see how to create <strong>and</strong> control queues, <strong>and</strong> how to send <strong>and</strong> receive messages.<br />

You also build a small course order application that consists of a sending <strong>and</strong> a receiving part.<br />

Creating a message queue<br />

You ’ ve already seen how to create message queues with the Computer Management utility. Message queues<br />

can be created programmatically with the Create() method of the MessageQueue class.<br />

With the Create() method, the path of the new queue must be passed. The path consists of the host<br />

name where the queue is located <strong>and</strong> the name of the queue. In the following example, the queue<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!