ResponseQueueInfo
MSMQMessage

The ResponseQueueInfo property specifies a queue for receiving response messages from the target application.

Type: MSMQQueueInfo
Run time: read/write

Syntax

set object1.ResponseQueueInfo = object2
 
Syntax Element Description
object1 Message (MSMQMessage) object that represents the message.
object2 Queue information (MSMQQueueInfo) object that represents the response queue.

Settings

MSMQQueueInfo object.

Remarks

ResponseQueueInfo is used to send the format name of another queue to the receiving application. Typically, this is done so that the receiving application can send response messages back to the sending application. For information on response queues, see Response Queues.

Note  The MSMQQueueInfo object of a private queue (which would be inaccessible otherwise) can also be sent using queuinfoResponse.

Messages returned to the queue are application defined. The application must define what is in the messages as well as what is to be done when a message is received.

For a complete example of sending a message that requests a response plus sending the response, see Sending Messages that Request a Response.

Example

This example locates a response and destination queue (creating them if needed), sends a message to the destination queue, and retrieves the message and sends a response message back to the response queue. To coordinate between the two messages, the correlation identifier of the response message (CorrelationId) is set to the message identifier of the original message.

To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, run the example, and click the form.

Dim query As New MSMQQuery
Dim qinfos As MSMQQueueInfos
Dim qinfoResp, As MSMQQueueInfo
Dim qinfoDest As MSMQQueueInfo
Dim qRead As New MSMQQueue
Dim qResp As MSMQQueue
Dim msgSent As New MSMQMessage
Dim msgRead As MSMQMessage
Dim msgResp As New MSMQMessage

Private Sub Form_Click()
   
   '**********************************
   ' Locate response queue (create one
   ' if one doesn't exist).
   '**********************************
   Set qinfos = query.LookupQueue(Label:="Response Queue")
   qinfos.Reset
   Set qinfoResp = qinfos.Next
   If qinfoResp Is Nothing Then
      Set qinfoResp = New MSMQQueueInfo
      qinfoResp.PathName = ".\RespQueue"
      qinfoResp.Label = "Response Queue"
      qinfoResp.Create
   End If
   '**********************************
   ' Locate destination queue
   '(create one if one doesn't exist).
   '**********************************
   Set qinfos = query.LookupQueue(Label:="Destination Queue")
   qinfos.Reset
   Set qinfoDest = qinfos.Next
   If qinfoDest Is Nothing Then
      Set qinfoDest = New MSMQQueueInfo
      qinfoDest.PathName = ".\DestQueue"
      qinfoDest.Label = "Destination Queue"
      qinfoDest.Create
   End If
   
   '************************
   ' Open destination queue.
   '************************
   Set q = qinfoDest.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   
   '**************
   ' Send Message.
   '**************
   msgSent.Label = "Test Message"
   msgSent.Body = "This message tests the response queue."
   Set msgSent.ResponseQueueInfo = qinfoResp
   msgSent.Send q
  
   MsgBox "The message was sent to the following queue: " + qinfoDest.QueueGuid + ". Check the MSMQ Explorer to see the message in the queue."
   q.Close
  
   '************************************
   ' Read the message in the destination
   ' queue and send response message if
   ' one is requested.
   '************************************
   Set q = qinfoDest.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)
   Set msgRead = q.Receive
   
   Set qResp = msgRead.ResponseQueueInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   msgResp.Label = "Response Message"
   msgResp.Body = "This is a response message"
   msgResp.CorrelationId = msgRead.Id
   msgResp.Send qResp
   MsgBox "The response message was sent to the following queue: " + msgRead.ResponseQueueInfo.QueueGuid
   
    
End Sub
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mqoai.h.
  Import Library: Use mqoa.lib.
  Unicode: Defined only as Unicode.

See Also

Body, Close, Create, CorrelationId, Id, Label, LookupQueue, MSMQMessage, MSMQQuery, MSMQQueue, MSMQQueueInfo, MSMQQueueInfos, Next, Open, PathName, Receive, Reset, Send