Delivery
MSMQMessage

The Delivery property specifies how MSMQ delivers the message.

Type: Long
Run time: read/write

Syntax

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

Settings

The Delivery property can have one of the following values:

MQMSG_DELIVERY_RECOVERABLE
In every hop along its route, the message is forwarded to the next hop or stored locally in a backup file until delivered. This guarantees delivery even in the case of a computer crash.
MQMSG_DELIVERY_EXPRESS
The default. The message stays in memory until it can be delivered. (In-memory message store and forward.)

Remarks

When the message's delivery mechanism is set to MQMSG_DELIVERY_EXPRESS, the message has faster throughput. When set to MQMSG_DELIVERY_RECOVERABLE, throughput may be slower; however, MSMQ guarantees that the message will be delivered, even if a computer crashes while the message is enroute to the queue.

MSMQ always sets the delivery mechanism of transactional messages to MQMSG_DELIVERY_RECOVERABLE. For information on transactions, see MSMQ Transactions.

Example

This example first creates and opens a queue for sending messages and then sets the delivery mechanism for a message and sends it off to the queue.

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 qinfo As MSMQQueueInfo
Dim q As MSMQQueue
Dim msg As New MSMQMessage

Private Sub Form_Click()
   '*************************
   ' Create queue (no error
   ' handling if queue exists).
   '**************************
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = ".\DeliveryTest"
  qinfo.Label = "Test Queue"
  qinfo.Create
   '**************
   ' Open queue.
   '**************
  Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   '**************
   ' Send Messages.
   '**************
  msg.Label = "Test Message"
  msg.Body = "This is a test message with a string Body."
  msg.Delivery = MQMSG_DELIVERY_RECOVERABLE
  
  msg.Send q
  
  MsgBox "The message was sent. Use the MSMQ Explorer to see the message in the queue."
  
  q.Close

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, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Send