MessageQueue.ReceiveByLookupId 方法

定義

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 接收佇列中的特定訊息。Receives a specific message from the queue. 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。The message can be specified by a lookup identifier or by its position at the front or end of the queue.

多載

ReceiveByLookupId(Int64)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 接收符合非交易佇列之指定查詢識別項的訊息。Receives the message that matches the given lookup identifier from a non-transactional queue.

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransaction)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 接收交易佇列中的特定訊息。Receives a specific message from a transactional queue. 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。The message can be specified by a lookup identifier or by its position at the front or end of the queue.

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransactionType)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 使用指定的交易內容接收佇列中的特定訊息。Receives a specific message from the queue, using the specified transaction context. 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。The message can be specified by a lookup identifier or by its position at the front or end of the queue.

ReceiveByLookupId(Int64)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 接收符合非交易佇列之指定查詢識別項的訊息。Receives the message that matches the given lookup identifier from a non-transactional queue.

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

要接收訊息的 LookupIdThe LookupId of the message to receive.

傳回

Message

傳入符合 lookupId 參數的 MessageLookupIdThe Message whose LookupId property matches the lookupId parameter passed in.

例外狀況

未安裝 MSMQ 3.0。MSMQ 3.0 is not installed.

找不到具有指定 lookupId 的訊息。The message with the specified lookupId could not be found.

存取訊息佇列方法時發生錯誤。An error occurred when accessing a Message Queuing method.

備註

使用這個方法可讀取具有已知查閱識別碼的訊息,並將它從佇列中移除。Use this method to read a message with a known lookup identifier and remove it from the queue. 如果訊息不在佇列中,這個方法會立即擲回例外狀況。This method throws an exception immediately if the message is not in the queue.

LookupId訊息的屬性對訊息所在的佇列是唯一的,因此佇列中最多隻會有一個訊息符合指定的 lookupId 參數。The LookupId property of a message is unique to the queue where the message resides, so there will be at most one message in the queue that matches the given lookupId parameter.

若要讀取具有指定之查閱識別碼的訊息,而不將它從佇列中移除,請使用 PeekByLookupId 方法。To read a message with a specified lookup identifier without removing it from the queue, use the PeekByLookupId method.

下表顯示此方法是否適用于各種工作組模式。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer Yes
本機電腦和直接格式名稱Local computer and direct format name Yes
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name Yes

另請參閱

適用於

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransaction)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 接收交易佇列中的特定訊息。Receives a specific message from a transactional queue. 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。The message can be specified by a lookup identifier or by its position at the front or end of the queue.

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 值,指定如何在佇列中讀取訊息。One of the MessageLookupAction values, specifying how the message is read in the queue. 請指定下列其中一個選項:Specify one of the following: MessageLookupAction.Current:接收 lookupId 指定的訊息,並且從佇列中移除。MessageLookupAction.Current: Receives the message specified by lookupId and removes it from the queue.

MessageLookupAction.Next:接收 lookupId 指定的訊息後面的訊息,並且從佇列中移除。MessageLookupAction.Next: Receives the message following the message specified by lookupId and removes it from the queue.

MessageLookupAction.Previous:接收 lookupId 指定的訊息前面的訊息,並且從佇列中移除。MessageLookupAction.Previous: Receives the message preceding the message specified by lookupId and removes it from the queue.

MessageLookupAction.First:接收佇列中的第一則訊息,並且從佇列中移除。MessageLookupAction.First: Receives the first message in the queue and removes it from the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

MessageLookupAction.Last:接收佇列中的最後一則訊息,並且從佇列中移除。MessageLookupAction.Last: Receives the last message in the queue and removes it from the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

lookupId
Int64

要接收之訊息的 LookupId,或者為 0。The LookupId of the message to receive, or 0. 存取佇列中第一則或最後一則訊息時會使用 0。0 is used when accessing the first or last message in the queue.

傳回

Message

傳入之 lookupIdaction 參數所指定的 MessageThe Message specified by the lookupId and action parameters passed in.

例外狀況

未安裝 MSMQ 3.0。MSMQ 3.0 is not installed.

找不到具有指定 lookupId 的訊息。The message with the specified lookupId could not be found.

存取訊息佇列方法時發生錯誤。An error occurred when accessing a Message Queuing method.

-或--or-

該佇列是非交易式佇列。The queue is non-transactional.

action 參數不是其中一個 MessageLookupAction 成員。The action parameter is not one of the MessageLookupAction members.

備註

使用這個方法來讀取具有已知查閱識別碼的訊息,並使用參數所定義的交易內容將它從佇列中移除 transactionUse this method to read a message with a known lookup identifier and remove it from the queue, using a transaction context defined by the transaction parameter. 如果訊息不在佇列中,這個方法會立即擲回例外狀況。This method throws an exception immediately if the message is not in the queue.

LookupId訊息的屬性對訊息所在的佇列是唯一的,因此佇列中最多隻會有一個訊息符合指定的 lookupId 參數。The LookupId property of a message is unique to the queue where the message resides, so there will be at most one message in the queue that matches the given lookupId parameter.

因為在交易式佇列上呼叫這個方法,所以如果交易中止,則會將接收到的訊息傳回佇列。Because this method is called on a transactional queue, the message that is received would be returned to the queue if the transaction is aborted. 在認可交易之前,訊息不會從佇列中永久移除。The message is not permanently removed from the queue until the transaction is committed.

若要讀取具有指定之識別碼的訊息,而不將它從佇列中移除,請使用 PeekByLookupId 方法。To read a message with a specified identifier without removing it from the queue, use the PeekByLookupId method. 沒有與的呼叫所傳回的訊息相關聯的交易內容 PeekByLookupIdThere is no transaction context associated with a message returned by a call to PeekByLookupId. 因為不 PeekByLookupId 會從佇列中移除任何訊息,所以如果交易已經中止,就不會回復任何專案。Because PeekByLookupId does not remove any messages from the queue, there would be nothing to roll back if the transaction were aborted.

下表顯示此方法是否適用于各種工作組模式。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer Yes
本機電腦和直接格式名稱Local computer and direct format name Yes
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name Yes

另請參閱

適用於

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransactionType)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 使用指定的交易內容接收佇列中的特定訊息。Receives a specific message from the queue, using the specified transaction context. 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。The message can be specified by a lookup identifier or by its position at the front or end of the queue.

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 值,指定如何在佇列中讀取訊息。One of the MessageLookupAction values, specifying how the message is read in the queue. 請指定下列其中一個選項:Specify one of the following: MessageLookupAction.Current:接收 lookupId 指定的訊息,並且從佇列中移除。MessageLookupAction.Current: Receives the message specified by lookupId and removes it from the queue.

MessageLookupAction.Next:接收 lookupId 指定的訊息後面的訊息,並且從佇列中移除。MessageLookupAction.Next: Receives the message following the message specified by lookupId and removes it from the queue.

MessageLookupAction.Previous:接收 lookupId 指定的訊息前面的訊息,並且從佇列中移除。MessageLookupAction.Previous: Receives the message preceding the message specified by lookupId and removes it from the queue.

MessageLookupAction.First:接收佇列中的第一則訊息,並且從佇列中移除。MessageLookupAction.First: Receives the first message in the queue and removes it from the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

MessageLookupAction.Last:接收佇列中的最後一則訊息,並且從佇列中移除。MessageLookupAction.Last: Receives the last message in the queue and removes it from the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

lookupId
Int64

要接收之訊息的 LookupId,或者為 0。The LookupId of the message to receive, or 0. 存取佇列中第一則或最後一則訊息時會使用 0。0 is used when accessing the first or last message in the queue.

transactionType
MessageQueueTransactionType

其中一個 MessageQueueTransactionType 值,描述要與訊息相關聯的異動內容的類型。One of the MessageQueueTransactionType values, describing the type of transaction context to associate with the message.

傳回

Message

傳入之 actionlookupId 參數所指定的 MessageThe Message specified by the action and lookupId parameters passed in.

例外狀況

未安裝 MSMQ 3.0。MSMQ 3.0 is not installed.

找不到具有指定 lookupId 的訊息。The message with the specified lookupId could not be found.

存取訊息佇列方法時發生錯誤。An error occurred when accessing a Message Queuing method.

action 參數不是其中一個 MessageLookupAction 成員。The action parameter is not one of the MessageLookupAction members.

-或--or- transactionType 參數不是其中一個 MessageQueueTransactionType 成員。The transactionType parameter is not one of the MessageQueueTransactionType members.

備註

使用這個方法來讀取具有已知查閱識別碼的訊息,並使用參數所定義的交易內容將它從佇列中移除 transactionTypeUse this method to read a message with a known lookup identifier and remove it from the queue, using a transaction context defined by the transactionType parameter. 如果訊息不在佇列中,這個方法會立即擲回例外狀況。This method throws an exception immediately if the message is not in the queue.

LookupId訊息的屬性對訊息所在的佇列是唯一的,因此佇列中最多隻會有一個訊息符合指定的 lookupId 參數。The LookupId property of a message is unique to the queue where the message resides, so there will be at most one message in the queue that matches the given lookupId parameter.

若要讀取具有指定之識別碼的訊息,而不將它從佇列中移除,請使用 PeekByLookupId 方法。To read a message with a specified identifier without removing it from the queue, use the PeekByLookupId method. 沒有與的呼叫所傳回的訊息相關聯的交易內容 PeekByLookupIdThere is no transaction context associated with a message returned by a call to PeekByLookupId. 因為不 PeekByLookupId 會從佇列中移除任何訊息,所以如果交易已經中止,就不會回復任何專案。Because PeekByLookupId does not remove any messages from the queue, there would be nothing to roll back if the transaction were aborted.

Automatic transactionType 如果已經有附加到您想要用來接收訊息之執行緒的外部交易內容,請指定參數。Specify Automatic for the transactionType parameter if there is already an external transaction context attached to the thread that you want to use to receive the message. 指定 Single 是否要以單一內部交易接收訊息。Specify Single if you want to receive the message as a single internal transaction. 您可以指定 None 是否要從交易內容外的交易式佇列接收訊息。You can specify None if you want to receive a message from a transactional queue outside of a transaction context.

如果呼叫這個方法來接收交易式佇列中的訊息,則如果交易中止,則會將接收到的訊息傳回佇列。If this method is called to receive a message from a transactional queue, the message that is received would be returned to the queue if the transaction is aborted. 在認可交易之前,訊息不會從佇列中永久移除。The message is not permanently removed from the queue until the transaction is committed.

下表顯示此方法是否適用于各種工作組模式。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer Yes
本機電腦和直接格式名稱Local computer and direct format name Yes
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name Yes

另請參閱

適用於