NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Message.UseDeadLetterQueue

Gets or sets a value indicating whether a copy of an undeliverable message should be sent to a dead-letter queue.

[Visual Basic]
Overridable Public Property UseDeadLetterQueue As Boolean
[C#]
public bool UseDeadLetterQueue {virtual get; virtual set;}
[C++]
public: __property virtual bool get_UseDeadLetterQueue();
public: __property virtual void set_UseDeadLetterQueue(bool);
[JScript]
public function get UseDeadLetterQueue() : Boolean;
public function set UseDeadLetterQueue(Boolean);

Property Value

true if message delivery failure results in a copy of the message being sent to a dead-letter queue; otherwise, false. The default is false.

Exceptions

Exception Type Condition
InvalidOperationException The message queue is filtered not to read the UseDeadLetterQueue property.

Remarks

UseDeadLetterQueue provides access to a part of the functionality of the Journal property of the Message Queuing MSMQMessage object. The Journal property is accessed by both UseDeadLetterQueue and UseJournalQueue in the Message object.

In case of delivery failure for non-transactional messages, the message is sent to the non-transactional dead-letter queue on the computer that could not deliver the message (for example, if a message timeout expires.)

In the case of delivery failure for transactional messages, the message is sent to the transactional dead-letter queue on the source computer in all negative and in-doubt cases.

When you store messages in a dead-letter queue, clear the queue periodically to remove messages that are no longer needed. Messages stored in dead-letter queues count against the quota for the computer where the queue resides.

Note   The computer quota is set by the administrator.

Example [Visual Basic]

The following example creates an empty message. The example populates the Message with a string Body, sets the UseDeadLetterQueue property according to the priority, and then sends the message to a queue. It assumes there is a queue on the computer "myComputer" with the name "myQueue".

Note   Choosing to set the System.Messaging.Message.UserDeadLetterQueue property according to the priority is arbitrary and used only for illustrative purposes. A relation between the two is not necessary.

Import the System.Messaging namespace for this example.

[Visual Basic]

Private Sub CreateMessage(ByVal priority As MessagePriority)
    'Declare a message and message queue
    Dim msg As Message
    Dim mq As MessageQueue
    
    'Instantiate an empty message object
    msg = New Message
   
    'Instantiate a new MessageQueue object
    mq = New MessageQueue("myComputer\myQueue")

    If priority = MessagePriority.Highest Then
        'Use the deadletter queue for the message
        msg.UseDeadLetterQueue = True
    Else
        'Don't use the deadletter queue for the message.
        msg.UseDeadLetterQueue = False
    End If

    msg.Body = "New Message Body"
    'Send the message to the queue.
    mq.Send(msg)
End Sub

See Also

Message Class | Message Members | System.Messaging Namespace