Read-only. The Class property indicates message type. A message can be a normal MSMQ message, a positive or negative (arrival and read) acknowledgment message, or a report message. This property is set by MSMQ.
Type: | Long |
Run time: | read-only |
object.Class
Syntax Element | Description |
---|---|
object | Message (MSMQMessage) object that represents the message. |
MSMQ sets the Class property to one of the following values:
Normal messages (all messages created by your application):
Positive acknowledgment messages (generated by MSMQ):
Negative arrival acknowledgment messages (generated by MSMQ):
Negative read acknowledgment messages (generated by MSMQ):
Report messages (generated by MSMQ):
Acknowledgment messages are generated by MSMQ whenever the sending application requests them. MSMQ returns the appropriate acknowledgment message to the administration queue that is specified by the sending application. For information on administration queues, see Administration Queues. For a complete discussion of requesting acknowledgment messages, see Sending Messages that Request Acknowledgments.
Report messages are generated by MSMQ whenever a report queue is defined at the source Queue Manager. For information on report queues, see Report Queues.
When reading messages in an administration queue or dead letter queue, retrieve Class to find out why the message was sent to the queue.
This example uses an administration queue to see if a message reaches its destination queue. It sends a message and then looks at the Class property of the acknowledgment message (returned by MSMQ) to see if the original message reached its destination. The destination and administration queues are created if they don't exist.
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 qinfoAdmin As MSMQQueueInfo
Dim qinfoDest As MSMQQueueInfo
Dim q As MSMQQueue
Dim msgSent As New MSMQMessage
Dim msgAdmin As MSMQMessage
Private Sub Form_Click()
'**********************************
' Locate administration queue
'(create one if one doesn't exist).
'**********************************
Set qinfos = query.LookupQueue(Label:="Administration Queue")
qinfos.Reset
Set qinfoAdmin = qinfos.Next
If qinfoAdmin Is Nothing Then
Set qinfoAdmin = New MSMQQueueInfo
qinfoAdmin.PathName = ".\AdminQueue"
qinfoAdmin.Label = "Administration Queue"
qinfoAdmin.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 acknowledgment messages."
msgSent.Ack = MQMSG_ACKNOWLEDGMENT_FULL_REACH_QUEUE
Set msgSent.AdminQueueInfo = qinfoAdmin
msgSent.Send q
MsgBox "The message was sent. Check the MSMQ Explorer to see the messages in the queue."
q.Close
'********************************
' Read Acknowledgment message in the
' administration queue.
'********************************
Set q = qinfoAdmin.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)
Set msgAdmin = q.Receive
If msgAdmin.Class = MQMSG_CLASS_ACK_REACH_QUEUE Then
MsgBox "The message reached the queue."
Else
MsgBox " The message did not reach the queue."
End If
End Sub
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.
Ack, AdminQueueInfo, Body, Close, Create, Label, LookupQueue, MSMQMessage, MSMQQueue, MSMQQueueInfo, MSMQQueueInfos, MSMQQuery, Next, Open, PathName, Receive, Reset, Send