Export (0) Print
Expand All

Programming for Location Independence

This topic describes how applications can locate and use location-independent mobile queues.

The term "mobile queue" is used to indicate a destination, not a specific queue. A specific mobile queue can be any public queue that is using a specific location-independent queue property, or set of properties, to identify itself.

For example, say you need to send messages to an account that can be in several different locations. By using a mobile queue for the account, the sending application can send messages to the account, regardless of which queue is currently being used as the destination.

ms701107.note(en-us,VS.85).gifNote
Message Queuing does not allow the queue itself to be moved. A queue cannot be moved from one computer to another because the identifier (GUID) of the queue cannot be altered. Message Queuing generates the queue identifier when the queue is created and adds information about the computer where the queue resides. This information cannot be changed.

To use mobile queues, the application must be able to identify the correct queue to use by one or more location-independent queue properties. For example, a combination of the queue service type and queue label can be used to uniquely identify a queue without reference to the location of the current queue being used.

Single Mobile Queues

If only one mobile queue is required, a queue's type GUID property can be used, instead of its instance property, to uniquely identify the queue. To give the appearance of moving the queue, delete the old queue and create a new destination queue using the same queue type GUID. The sending application will then always search for the queue type, finding the correct queue regardless of where it is located.

In this case, it is the application's responsibility to make sure that only one queue with the specific queue type exists at any time. For example, the sending application can monitor for the error MQ_ERROR_QUEUE_DELETED or negative acknowledgment messages to trigger a new lookup when sending messages.

Multiple Mobile Queues

If several mobile queues are required, a queue's type GUID property can be used to identify a group of mobile queues, and its label property can then be used to identify a specific queue in the group. In this case, a query (based on the queue type) can be run to locate all the mobile queues of a specific type. The application can then use the label to select a specific queue from among the query results.

To give the appearance of moving the queue, each time a new destination queue is created it is given the same queue type and label. Because the sending application always searches for this queue type and label, it finds the correct queue regardless of where it is located.

In this case, it is the application's responsibility to make sure that only one queue with the specific queue type and label exists at any time.

Show:
© 2014 Microsoft