Share via


PROPID_M_RESP_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

The PROPID_M_RESP_QUEUE property specifies the queue to which application-generated response messages are returned. This property is superseded by PROPID_M_RESP_FORMAT_NAME in MSMQ 3.0.

Property ID

PROPID_M_RESP_QUEUE

Type Indicator

VT_LPWSTR

MQPROPVARIANT Field

pwszVal

Property Value

Format name of the response queue (the default is none).

Remarks

PROPID_M_RESP_QUEUE is used to send the format name of a queue to the receiving application. Typically, this is done so that the receiving application can send a response message back to the sending application.

Note

Response messages are application-defined. The sending and receiving application must define what is in the message, as well as what is to be done when the response message arrives in the response queue.

This property can also be used to send the format name of other queues. For example, when sending response messages you can set this property to the format name of the destination queue of the original message. Or you can use this property to send the format name of a local private queue (which would be inaccessible otherwise) to another application.

To set the format name of a response queue, specify PROPID_M_RESP_QUEUE in the MQMSGPROPS structure and call MQSendMessage.

To find out where to send a response message, specify PROPID_M_RESP_QUEUE and PROPID_M_RESP_QUEUE_LEN in the MQMSGPROPS structure (the length property is used to verify that the format name was sent). Then call MQReceiveMessage and examine the returned values.

If MQReceiveMessage fails, returning an MQ_ERROR_FORMATNAME_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_RESP_QUEUE_LEN to reallocate the format name buffer and call MQReceiveMessage again.

Before using the returned format name, always check the length property PROPID_M_RESP_QUEUE_LEN to see if the format name was sent with the message. If the returned value of PROPID_M_RESP_QUEUE_LEN is 0, no format name was sent with the message. If the returned value is non-0, PROPID_M_RESP_QUEUE contains the format name of the queue.

Equivalent COM Property

With COM components, the equivalent property for setting and retrieving the response queue is MSMQMessage.ResponseQueueInfo.

For information on See
What is in a response message Response Messages
The type of queues used as response queues Response Queues
Testing to see if a response is needed PROPID_M_RESP_QUEUE_LEN

Example Code

The following code fragments show how PROPID_M_RESP_QUEUE is specified in arrays that can be used to initialize an MQMSGPROPS structure for setting and retrieving the response queue format name.

To Send the Format Name

aMsgPropId[i] = PROPID_M_RESP_QUEUE;               // Property ID  
aMsgPropVar[i].vt = VT_LPWSTR;                     // Type indicator  
aMsgPropVar[i].pwszVal = wszRespQueue;  
i++;  

To Retrieve the Format Name

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

The following example is included in Using Message Queuing.

For an example of See
Setting PROPID_M_RESP_QUEUE to request a response message C/C++ Code Example: Requesting Response Messages

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQSendMessage
PROPID_M_RESP_QUEUE_LEN