System.Messaging Reference (Document! X Sample)
System.Messaging Namespace / MessageQueue Class / ReceiveByLookupId Method / ReceiveByLookupId(MessageLookupAction,Int64,MessageQueueTransactionType) Method
One of the MessageLookupAction values, specifying how the message is read in the queue. Specify one of the following:MessageLookupAction.Current: Receives the message specified by lookupId and removes it from the queue.MessageLookupAction.Next: Receives the message following the message specified by lookupId and removes it from the queue.MessageLookupAction.Previous: Receives the message preceding the message specified by lookupId and removes it from the queue.MessageLookupAction.First: Receives the first message in the queue and removes it from the queue. The lookupId parameter must be set to 0.MessageLookupAction.Last: Receives the last message in the queue and removes it from the queue. The lookupId parameter must be set to 0.
The LookupId of the message to receive, or 0. 0 is used when accessing the first or last message in the queue.
One of the MessageQueueTransactionType values, describing the type of transaction context to associate with the message.



In This Topic
    ReceiveByLookupId(MessageLookupAction,Int64,MessageQueueTransactionType) Method
    In This Topic
    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.
    Syntax
    'Declaration
     
    
    Public Overloads Function ReceiveByLookupId( _
       ByVal action As MessageLookupAction, _
       ByVal lookupId As Long, _
       ByVal transactionType As MessageQueueTransactionType _
    ) As Message
    'Usage
     
    
    Dim instance As MessageQueue
    Dim action As MessageLookupAction
    Dim lookupId As Long
    Dim transactionType As MessageQueueTransactionType
    Dim value As Message
     
    value = instance.ReceiveByLookupId(action, lookupId, transactionType)

    Parameters

    action
    One of the MessageLookupAction values, specifying how the message is read in the queue. Specify one of the following:MessageLookupAction.Current: Receives the message specified by lookupId and removes it from the queue.MessageLookupAction.Next: Receives the message following the message specified by lookupId and removes it from the queue.MessageLookupAction.Previous: Receives the message preceding the message specified by lookupId and removes it from the queue.MessageLookupAction.First: Receives the first message in the queue and removes it from the queue. The lookupId parameter must be set to 0.MessageLookupAction.Last: Receives the last message in the queue and removes it from the queue. The lookupId parameter must be set to 0.
    lookupId
    The LookupId of the message to receive, or 0. 0 is used when accessing the first or last message in the queue.
    transactionType
    One of the MessageQueueTransactionType values, describing the type of transaction context to associate with the message.

    Return Value

    The Message specified by the action and lookupId parameters passed in.
    Exceptions
    ExceptionDescription
    MSMQ 3.0 is not installed.
    The message with the specified lookupId could not be found.
    An error occurred when accessing a Message Queuing method.
    The action parameter is not one of the MessageLookupAction members.-or- The transactionType parameter is not one of the MessageQueueTransactionType members.
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also