The Delivery property specifies how MSMQ delivers the message.
Type: | Long |
Run time: | read/write |
object.Delivery
Syntax Element | Description |
---|---|
object | Message (MSMQMessage) object that represents the message. |
The Delivery property can have one of the following values:
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.
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
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.
Body, Close, Create, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Send