Microsoft KB Archive/186191

= INFO: Dynamic Queue Deletion and Return Code for MQSendMessage =

Article ID: 186191

Article Last Modified on 9/1/1999

-

APPLIES TO


 * Microsoft Message Queue Server 1.0

-



This article was previously published under Q186191



SUMMARY
This article summarizes the return codes a Microsoft Message Queue Server (MSMQ) C API application sees that is operating on an open queue handle when the underlying queue instance is deleted from the Directory Service (DS).

In particular, MQSendMessage returns MQ_OK even if you delete the queue after opening it for Send in your C application. This behavior is by design as described below.



MORE INFORMATION
One way to simulate this scenario is to delete the queue in the Explorer after opening it in the application code.

If you delete the queue in Explorer after opening it in the application code, the MSMQ Send and Receive API returns the following codes:


 * MQSendMessage returns MQ_OK if you delete the queue after opening it for Send in your C application.
 * You receive a negative acknowledgment (bad destination) with MQMSG_CLASS_NACK_BAD_DST_Q as message class. To receive this acknowledgment, you must set up an admin queue and specify PROPID_M_ACKNOWLEDGE and PROPID_M_ADMIN_QUEUE when calling MQSendMessage. This is by design.

NOTE: The sending computer opens the queue only once and does not query for the queue's existence again. So, the sending computer does not query if the queue is deleted after it opened it successfully. The destination queue can be located on a remote disconnected site. The same behavior occurs for queues located on the sending computer to keep the programming model coherent.
 * MQReceiveMessage returns an explicit error MQ_ERROR_QUEUE_DELETED if either the queue is deleted while your receive is pending or when you call receive using a handle to queue that has already been deleted.

