共用方式為


PROPID_M_DEST_QUEUE

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

(Read-only.) The PROPID_M_DEST_QUEUE property identifies the original destination queue of a message.

Property ID

PROPID_M_DEST_QUEUE

Type Indicator

VT_LPWSTR

MQPROPVARIANT Field

pwszVal

Property Value

Format name of the original destination queue.

Remarks

The PROPID_M_DEST_QUEUE property is only used by the receiving application. Message Queuing attaches this property to the message according to the destination queue specified in the call to MQSendMessage. It is typically retrieved in the following cases.

  • To determine the original destination queue of a message that Message Queuing puts in a journal queue.

  • To determine the original destination queue of a message that Message Queuing puts in a dead-letter queue.

  • To provide the original destination queue when returning response message back to a response queue.

When a message is sent to multiple destinations, Message Queuing sets this property to the specific destination of each copy of the message.

To retrieve the format name of the destination queue for a message, specify PROPID_M_DEST_QUEUE and PROPID_M_DEST_QUEUE_LEN in the MQMSGPROPS structure. Then call MQReceiveMessage or MQReceiveMessageByLookupId and examine the returned values.

If MQReceiveMessage or MQReceiveMessageByLookupId fails, returning an MQ_ERROR_FORMATNAME_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_DEST_QUEUE_LEN to reallocate the format name buffer. Then, call the applicable function again.

Equivalent COM Property

With COM components, the equivalent property for retrieving the original destination of a message is MSMQMessage.DestinationQueueInfo.

Example Code

The following code fragment shows how PROPID_M_DEST_QUEUE is specified in arrays that can be used to initialize an MQMSGPROPS structure for retrieving the destination queue format name.

ULONG ulBufferLength = 256;  
WCHAR * wszDestQueueBuffer = NULL;  
wszDestQueueBuffer = (WCHAR*)malloc(ulBufferLength*sizeof(WCHAR));  
if (wszDestQueueBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(wszDestQueueBuffer, 0, ulBufferLength*sizeof(WCHAR));  
aMsgPropId[i] = PROPID_M_DEST_QUEUE;             // Property ID  
aMsgPropVar[i].vt = VT_LPWSTR;                   // Type indicator  
aMsgPropVar[i].pwszVal = wszDestQueueBuffer;  
i++;  
  
aMsgPropId[i] = PROPID_M_DEST_QUEUE_LEN;         // Property ID  
aMsgPropVar[i].vt = VT_UI4;                      // Type indicator  
aMsgPropVar[i].ulVal = ulBufferLength;  
i++;  
  
// Reallocate memory for the destination queue format name buffer if necessary.  
wszDestQueueBuffer = (WCHAR*)realloc(wszDestQueueBuffer, aMsgPropVar[1].ulVal*sizeof(WCHAR));  
if (wszDestQueueBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(wszDestQueueBuffer, 0, aMsgPropVar[1].ulVal*sizeof(WCHAR));  
aMsgPropVar[0].pwszVal = wszDestQueueBuffer;     // Pointer to the new buffer  

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
PROPID_M_DEST_QUEUE_LEN