MessageQueue.PeekByLookupId 方法

定義

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 窺視佇列中的特定訊息。Peeks at 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.

多載

PeekByLookupId(Int64)

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

PeekByLookupId(MessageLookupAction, Int64)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 窺視佇列中的特定訊息。Peeks at 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.

PeekByLookupId(Int64)

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

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

參數

lookupId
Int64

要窺視之訊息的 LookupIdThe LookupId of the message to peek at.

傳回

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 without removing 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.

若要讀取具有指定之查閱識別碼的訊息,並將它從佇列中移除,請使用 ReceiveByLookupId 方法。To read a message with a specified lookup identifier and remove it from the queue, use the ReceiveByLookupId 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

另請參閱

適用於

PeekByLookupId(MessageLookupAction, Int64)

在 MSMQ 3.0 中介紹。Introduced in MSMQ 3.0. 窺視佇列中的特定訊息。Peeks at 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.

public:
 System::Messaging::Message ^ PeekByLookupId(System::Messaging::MessageLookupAction action, long lookupId);
public System.Messaging.Message PeekByLookupId (System.Messaging.MessageLookupAction action, long lookupId);
member this.PeekByLookupId : System.Messaging.MessageLookupAction * int64 -> System.Messaging.Message
Public Function PeekByLookupId (action As MessageLookupAction, lookupId As Long) 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: Peeks at the message specified by lookupId.

MessageLookupAction.Next:窺視 lookupId 指定的訊息後面的訊息。MessageLookupAction.Next: Peeks at the message following the message specified by lookupId.

MessageLookupAction.Previous:窺視 lookupId 指定的訊息前面的訊息。MessageLookupAction.Previous: Peeks at the message preceding the message specified by lookupId.

MessageLookupAction.First:窺視佇列中的第一則訊息。MessageLookupAction.First: Peeks at the first message in the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

MessageLookupAction.Last:窺視佇列中的最後一則訊息。MessageLookupAction.Last: Peeks at the last message in the queue. lookupId 參數必須設定為 0。The lookupId parameter must be set to 0.

lookupId
Int64

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

傳回

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.

備註

使用這個方法來讀取具有已知查閱識別碼的訊息,而不將它從佇列中移除。Use this method to read a message with a known lookup identifier without removing 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.

若要讀取具有指定之識別碼的訊息,並將它從佇列中移除,請使用 ReceiveByLookupId 方法。To read a message with a specified identifier and remove it from the queue, use the ReceiveByLookupId 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

另請參閱

適用於