Class
MSMQMessage

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.

Quick Info

Type: Long
Run time: read-only

Syntax

object.Class
 
Syntax Element Description
object Message (MSMQMessage) object that represents the message.

Return Values

MSMQ sets the Class property to one of the following values:

Normal messages (all messages created by your application):
MQMSG_CLASS_NORMAL
A normal MSMQ message.
Positive acknowledgment messages (generated by MSMQ):
MQMSG_CLASS_ACK_REACH_QUEUE
The original message reached its destination queue.
MQMSG_CLASS_ACK_RECEIVE
The original message was retrieved by the receiving application.
Negative arrival acknowledgment messages (generated by MSMQ):
MQMSG_CLASS_NACK_ACCESS_DENIED
The sending application does not have access rights to the destination queue.
MQMSG_CLASS_NACK_BAD_DST_Q
The destination queue is not available to the sending application.
MQMSG_CLASS_NACK_BAD_ENCRYPTION
The destination Queue Manager could not decrypt a private (encrypted) message (see PrivLevel).
MQMSG_CLASS_NACK_BAD_SIGNATURE
MSMQ could not authenticate the original message. The original message's digital signature is not valid.
MQMSG_CLASS_NACK_COULD_NOT_ENCRYPT
The source Queue Manager could not encrypt a private message (see PrivLevel).
MQMSG_CLASS_NACK_HOP_COUNT_EXCEEDED
The original message's hop count is exceeded.
MQMSG_CLASS_NACK_Q_EXCEED_QUOTA
The original message's destination queue is full.
MQMSG_CLASS_NACK_REACH_QUEUE_TIMEOUT
Either the time-to-reach-queue or time-to-be-received timer expired before the original message could reach the destination queue.
MQMSG_CLASS_NACK_PURGED
The message was purged before reaching the destination queue.
MQMSG_CLASS_NACK_NOT_TRANSACTIONAL_Q
A transaction message was sent to a non-transaction queue.
MQMSG_CLASS_NACK_NOT_TRANSACTIONAL_MSG
A non-transaction message was sent to a transaction queue.
Negative read acknowledgment messages (generated by MSMQ):
MQMSG_CLASS_NACK_Q_DELETED
The queue was deleted before the message could be read from the queue.
MQMSG_CLASS_NACK_Q_PURGED
The queue was purged and the message no longer exists.
MQMSG_CLASS_NACK_RECEIVE_TIMEOUT
The original message was not removed from the queue before its time-to-be-received timer expired.
Report messages (generated by MSMQ):
MQMSG_CLASS_REPORT
Sent each time the message enters or leaves an MSMQ server.

Remarks

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, 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.

Example

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, and then 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 
 

See Also

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


© 1997 by Microsoft Corporation. All rights reserved.