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 en-route 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, 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, and then 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
Body, Close, Create, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Send