MessageQueue.ReceiveByLookupId 方法

定義

在 MSMQ 3.0 中介紹。 接收佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

多載

ReceiveByLookupId(Int64)

在 MSMQ 3.0 中介紹。 接收符合非交易佇列之指定查詢識別項的訊息。

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransaction)

在 MSMQ 3.0 中介紹。 接收交易佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransactionType)

在 MSMQ 3.0 中介紹。 使用指定的交易內容接收佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

ReceiveByLookupId(Int64)

在 MSMQ 3.0 中介紹。 接收符合非交易佇列之指定查詢識別項的訊息。

public:
 System::Messaging::Message ^ ReceiveByLookupId(long lookupId);
public System.Messaging.Message ReceiveByLookupId (long lookupId);
member this.ReceiveByLookupId : int64 -> System.Messaging.Message
Public Function ReceiveByLookupId (lookupId As Long) As Message

參數

lookupId
Int64

要接收訊息的 LookupId

傳回

傳入符合 lookupId 參數的 MessageLookupId

例外狀況

未安裝 MSMQ 3.0。

找不到具有指定 lookupId 的訊息。

存取訊息佇列方法時發生錯誤。

備註

使用此方法可讀取具有已知查閱標識符的訊息,並將其從佇列中移除。 如果訊息不在佇列中,這個方法會立即擲回例外狀況。

訊息 LookupId 的 屬性對訊息所在的佇列而言是唯一的,因此佇列中最多會有一個符合指定 lookupId 參數的訊息。

若要讀取具有指定查閱標識碼的訊息,而不從佇列中移除它,請使用 PeekByLookupId 方法。

下表顯示這個方法是否可在各種工作組模式中使用。

工作組模式 可用
本機電腦
本機計算機和直接格式名稱
遠端電腦
遠端電腦和直接格式名稱

另請參閱

適用於

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransaction)

在 MSMQ 3.0 中介紹。 接收交易佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

public:
 System::Messaging::Message ^ ReceiveByLookupId(System::Messaging::MessageLookupAction action, long lookupId, System::Messaging::MessageQueueTransaction ^ transaction);
public System.Messaging.Message ReceiveByLookupId (System.Messaging.MessageLookupAction action, long lookupId, System.Messaging.MessageQueueTransaction transaction);
member this.ReceiveByLookupId : System.Messaging.MessageLookupAction * int64 * System.Messaging.MessageQueueTransaction -> System.Messaging.Message
Public Function ReceiveByLookupId (action As MessageLookupAction, lookupId As Long, transaction As MessageQueueTransaction) As Message

參數

action
MessageLookupAction

其中一個 MessageLookupAction 值,指定如何在佇列中讀取訊息。 請指定下列其中一個選項:

MessageLookupAction.Current:接收 lookupId 指定的訊息,並且從佇列中移除。

MessageLookupAction.Next:接收 lookupId 指定的訊息後面的訊息,並且從佇列中移除。

MessageLookupAction.Previous:接收 lookupId 指定的訊息前面的訊息,並且從佇列中移除。

MessageLookupAction.First:接收佇列中的第一則訊息,並且從佇列中移除。 lookupId 參數必須設定為 0。

MessageLookupAction.Last:接收佇列中的最後一則訊息,並且從佇列中移除。 lookupId 參數必須設定為 0。

lookupId
Int64

要接收之訊息的 LookupId,或者為 0。 存取佇列中第一則或最後一則訊息時會使用 0。

傳回

傳入之 lookupIdaction 參數所指定的 Message

例外狀況

未安裝 MSMQ 3.0。

找不到具有指定 lookupId 的訊息。

存取訊息佇列方法時發生錯誤。

-或-

該佇列是非交易式佇列。

action 參數不是其中一個 MessageLookupAction 成員。

備註

使用這個方法來讀取具有已知查閱標識符的訊息,並使用 參數所 transaction 定義的交易內容,從佇列中移除該訊息。 如果訊息不在佇列中,這個方法會立即擲回例外狀況。

訊息 LookupId 的 屬性對訊息所在的佇列而言是唯一的,因此佇列中最多會有一個符合指定 lookupId 參數的訊息。

因為這個方法是在交易佇列上呼叫,所以如果交易已中止,就會將收到的訊息傳回至佇列。 在認可交易之前,不會從佇列永久移除訊息。

若要讀取具有指定標識符的訊息,而不從佇列中移除它,請使用 PeekByLookupId 方法。 呼叫 所 PeekByLookupId傳回的訊息沒有相關聯的交易內容。 由於 PeekByLookupId 不會從佇列中移除任何訊息,因此如果交易中止,則不會復原任何訊息。

下表顯示這個方法是否可在各種工作組模式中使用。

工作組模式 可用
本機電腦
本機計算機和直接格式名稱
遠端電腦
遠端電腦和直接格式名稱

另請參閱

適用於

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransactionType)

在 MSMQ 3.0 中介紹。 使用指定的交易內容接收佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

public:
 System::Messaging::Message ^ ReceiveByLookupId(System::Messaging::MessageLookupAction action, long lookupId, System::Messaging::MessageQueueTransactionType transactionType);
public System.Messaging.Message ReceiveByLookupId (System.Messaging.MessageLookupAction action, long lookupId, System.Messaging.MessageQueueTransactionType transactionType);
member this.ReceiveByLookupId : System.Messaging.MessageLookupAction * int64 * System.Messaging.MessageQueueTransactionType -> System.Messaging.Message
Public Function ReceiveByLookupId (action As MessageLookupAction, lookupId As Long, transactionType As MessageQueueTransactionType) As Message

參數

action
MessageLookupAction

其中一個 MessageLookupAction 值,指定如何在佇列中讀取訊息。 請指定下列其中一個選項:

MessageLookupAction.Current:接收 lookupId 指定的訊息,並且從佇列中移除。

MessageLookupAction.Next:接收 lookupId 指定的訊息後面的訊息,並且從佇列中移除。

MessageLookupAction.Previous:接收 lookupId 指定的訊息前面的訊息,並且從佇列中移除。

MessageLookupAction.First:接收佇列中的第一則訊息,並且從佇列中移除。 lookupId 參數必須設定為 0。

MessageLookupAction.Last:接收佇列中的最後一則訊息,並且從佇列中移除。 lookupId 參數必須設定為 0。

lookupId
Int64

要接收之訊息的 LookupId,或者為 0。 存取佇列中第一則或最後一則訊息時會使用 0。

transactionType
MessageQueueTransactionType

其中一個 MessageQueueTransactionType 值,描述要與訊息相關聯的異動內容的類型。

傳回

傳入之 actionlookupId 參數所指定的 Message

例外狀況

未安裝 MSMQ 3.0。

找不到具有指定 lookupId 的訊息。

存取訊息佇列方法時發生錯誤。

action 參數不是其中一個 MessageLookupAction 成員。

-或-

transactionType 參數不是其中一個 MessageQueueTransactionType 成員。

備註

使用這個方法來讀取具有已知查閱標識符的訊息,並使用 參數所 transactionType 定義的交易內容,從佇列中移除該訊息。 如果訊息不在佇列中,這個方法會立即擲回例外狀況。

訊息 LookupId 的 屬性對訊息所在的佇列而言是唯一的,因此佇列中最多會有一個符合指定 lookupId 參數的訊息。

若要讀取具有指定標識符的訊息,而不從佇列中移除它,請使用 PeekByLookupId 方法。 呼叫 所 PeekByLookupId傳回的訊息沒有相關聯的交易內容。 由於 PeekByLookupId 不會從佇列中移除任何訊息,因此如果交易中止,則不會復原任何訊息。

Automatic如果已經附加至您要用來接收訊息之線程的外部交易內容,請指定 transactionType 參數。 指定 Single 是否要以單一內部交易的形式接收訊息。 您可以指定 None 是否要從交易內容外部的交易佇列接收訊息。

如果呼叫這個方法以接收來自交易佇列的訊息,如果交易已中止,則收到的訊息會傳回至佇列。 在認可交易之前,不會從佇列永久移除訊息。

下表顯示這個方法是否可在各種工作組模式中使用。

工作組模式 可用
本機電腦
本機計算機和直接格式名稱
遠端電腦
遠端電腦和直接格式名稱

另請參閱

適用於