Microsoft KB Archive/172688
Article ID: 172688
Article Last Modified on 8/28/1999
- Microsoft Message Queue Server 1.0
This article was previously published under Q172688
You may want to write a Microsoft Message Queue Server (MSMQ) application for a single computer to generate and queue messages while offline and then, when later connected to the network, forward the messages to a remote application or notify the remote application that the local queue of messages is now available for it to open and read.
IMPORTANT: When writing an offline application using local queues, define the queues to be Recoverable. Using Express queues may lead to loss of messages.
The configuration targeted for individual offline operation is the Independent Client. The Dependent Client is incapable of operating offline. The Windows NT Server and SQL Server requirements of a Site controller configuration, while simpler to code for, would probably be impractical for a single offline user.
When the offline computer is an Independent client, you need to write the offline portion of the application carefully to avoid using APIs that query the Message Queue Server Information Store (MQIS). The MQIS is held only on site controllers (PEC/PSC/BSC). Using any API, like MQLocate, that requires consultation of the MQIS would attempt to generate network traffic, causing an error or timeout in the application.
To open a handle to a queue with no connection to a Falcon MQIS server you can do either of the following:
- Use the DIRECT= format.
- Use the GUID of the queue ("PUBLIC=" format).
After the queue is open, all messages will be stored by the QM for the application until connectivity is regained.
This format includes the target computer's name, or the target computer's network address, and local queue name of the target queue. This method can only be used when the target computer is directly connectable (one MSMQ hop) from the source computer.
Falcon routing will not take place with such addressing. The message is sent directly to the remote computer's queue as soon as the sending client regains connectivity with the remote computer. No access to the MQIS is required.
To specify the format name, you can do either of the following:
- Use the computer name (for example, \\mymachine).
- Use the TCP/IP address (for example, 22.214.171.124).
This method forces the application to store the address information of the target computer before disconnecting. If you choose to use the TCP/IP address, this can be problematic if you are also using DHCP, because the target computer may have changed network addresses since the source computer stored the address. While the computer name may have been changed while the source computer was disconnected, this is far less likely to have occurred.
This format requires your application to cache this GUID before disconnecting. The MQOpenQueue() will succeed offline, and then you can send messages, and close the queue handle, and quit the application. All messages will be stored by the QM for the application.
A connection to the MQIS server is eventually required using this method. To actually transfer messages to the remote destination queue , MSMQ needs to consult an MQIS server in order to resolve the GUID into a network address. If the MQIS server is down when the sending computer regains connectivity, the sending computer will not send the messages.
Private Sub OpenQueueOffline() Dim qinfo As MSMQQueueInfo Set qinfo = New MSMQQueueInfo Dim q As New MSMQQueue txtDirectFormatName = "DIRECT=TCP:126.96.36.199\wiley" qinfo.strPathName = "" qinfo.strFormatName = "" qinfo.strLabel = "" qinfo.strFormatName = txtDirectFormatName on error goto ErrorHandler Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE) If q.isOpen Then MsgBox "The queue " + qinfo.strPathName + " is open." Else MsgBox "The queue " + qinfo.strPathName + " is not open!" End If 'Clean up qinfo.strPathName = "" Set qinfo = Nothing Set q = Nothing Exit Function ErrorHandler: msgbox "error while opening queue: " qinfo.strPathName Exit Function End Sub
For more information, please see the MSMQ Offline Support section of the MSMQ software development kit (SDK).
Additional query words: app machine
Keywords: kbhowto kbinfo kbprogramming KB172688