MessageQueueTransaction MessageQueueTransaction MessageQueueTransaction MessageQueueTransaction Class

定義

提供訊息佇列內部交易。Provides a Message Queuing internal transaction.

public ref class MessageQueueTransaction : IDisposable
public class MessageQueueTransaction : IDisposable
type MessageQueueTransaction = class
    interface IDisposable
Public Class MessageQueueTransaction
Implements IDisposable
繼承
MessageQueueTransactionMessageQueueTransactionMessageQueueTransactionMessageQueueTransaction
實作

備註

要傳送或接收訊息的交易的一部分,您可以使用MessageQueueTransaction類別來建立交易,並將它傳遞給的多載MessageQueue.Send方法或MessageQueue.Receive採用方法transaction參數。To send or receive a message as part of a transaction, you can use the MessageQueueTransaction class to create a transaction and pass it to an overload of the MessageQueue.Send method or the MessageQueue.Receive method that takes a transaction parameter. 做為交易一部分傳送的訊息必須傳送至交易式佇列。Messages sent as part of a transaction must be sent to transactional queues. 使用指定的交易必須收到從交易式佇列接收訊息。Messages received from transactional queues must be received using a specified transaction.

除了Receive方法中,您可以接收與指定的識別項或指定的相互關聯識別項的訊息。In addition to the Receive method, you can receive messages with a specified identifier or specified correlation identifier. 請參閱ReceiveByIdReceiveByCorrelationId選擇性地從交易式佇列接收訊息的詳細資訊的方法。See the ReceiveById and ReceiveByCorrelationId methods for more information about selectively receiving messages from transactional queues.

如果認可交易時,會移除傳送至交易式佇列的訊息。Messages sent to transactional queues are removed if the transaction is committed. 同樣地,從交易式佇列接收的訊息會傳回佇列中,如果交易已回復。Similarly, messages received from transactional queues are returned to the queue if the transaction is rolled back.

如果您具現化MessageQueueTransaction並將它傳遞至適用的多載Send方法或Receive方法,以將訊息傳送至非異動式佇列或從非交易式佇列,此方法會收到一則訊息會擲回例外狀況,指出 「 錯誤交易使用量 」。If you instantiate a MessageQueueTransaction and pass it to an applicable overload of the Send method or Receive method to send a message to a non-transactional queue or receive a message from a non-transactional queue, the method throws an exception that indicates "Wrong Transaction Usage."

MessageQueueTransaction 為執行緒的 apartment 感知,因此,如果您的 apartment 狀態STA,您無法使用多個執行緒中的交易。MessageQueueTransaction is threading apartment aware, so if your apartment state is STA, you cannot use the transaction in multiple threads. Visual Basic 會將主執行緒的狀態STA,因此您必須套用MTAThreadAttributeMain副程式。Visual Basic sets the state of the main thread to STA, so you must apply the MTAThreadAttribute in the Main subroutine. 否則,使用其他執行緒傳送異動式訊息時,會擲回 MessageQueueException 例外狀況。Otherwise, sending a transactional message using another thread throws a MessageQueueException exception. 您套用MTAThreadAttribute使用下列的片段。You apply the MTAThreadAttribute by using the following fragment.

<System.MTAThreadAttribute>  
 public sub Main()  

建構函式

MessageQueueTransaction() MessageQueueTransaction() MessageQueueTransaction() MessageQueueTransaction()

初始化 MessageQueueTransaction 類別的新執行個體。Initializes a new instance of the MessageQueueTransaction class.

屬性

Status Status Status Status

取得交易的狀態。Gets the status of the transaction.

方法

Abort() Abort() Abort() Abort()

復原暫止的內部交易。Rolls back the pending internal transaction.

Begin() Begin() Begin() Begin()

開始新的訊息佇列內部交易。Begins a new Message Queuing internal transaction.

Commit() Commit() Commit() Commit()

認可一個暫止的內部交易。Commits a pending internal transaction.

Dispose() Dispose() Dispose() Dispose()

釋放 MessageQueueTransaction 所使用的所有資源。Releases all resources used by the MessageQueueTransaction.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 MessageQueueTransaction 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the MessageQueueTransaction and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

將目前執行個體所持有的資源釋出。Releases the resources held by the current instance.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.

另請參閱