Export (0) Print
Expand All

Message.TransactionId Property

Gets the identifier for the transaction of which the message was a part.

Namespace:  System.Messaging
Assembly:  System.Messaging (in System.Messaging.dll)

[MessagingDescriptionAttribute("MsgTransactionId")]
public string TransactionId { get; }

Property Value

Type: System.String
The identifier for the transaction associated with the message.

ExceptionCondition
InvalidOperationException

The message has not been sent. This property can only be read on messages retrieved from a queue.

-or-

The message queue is filtered to ignore the TransactionId property.

Receiving applications use the TransactionId property to verify that a message was sent as part of a specific transaction. The transaction identifier contains the identifier of the sending computer (first 16 bits) followed by a 4-byte transaction sequence number.

This property is available only for Message Queuing version 2.0 and later.

Transaction identifiers are not guaranteed to be unique, because transaction sequence numbers are not persistent, and they start over again at 2 20. Message Queuing guarantees only that subsequent transactions will have different transaction sequence numbers.

You can use the TransactionId property along with the IsFirstInTransaction and IsLastInTransaction properties to verify transaction boundaries.

The following code example displays the value of a message's TransactionId property.

// Display the value of the message's TransactionId property. 
// To view this property value, the queue's 
// MessageReadPropertyFilter.TransactionId property must be set to true 
// before the message is received.
Console.WriteLine("Message.TransactionId: {0}",
    orderMessage.TransactionId);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft