System.Messaging Reference (Document! X Sample)
PeekByCorrelationId(String,TimeSpan) Method



System.Messaging Namespace > MessageQueue Class > PeekByCorrelationId Method : PeekByCorrelationId(String,TimeSpan) Method
The CorrelationId of the message to peek.
A System.TimeSpan that indicates the time to wait until a new message is available for inspection.
Peeks the message that matches the given correlation identifier and waits until either a message with the specified correlation identifier is available in the queue, or the time-out expires.
Syntax
'Declaration
 
Public Overloads Function PeekByCorrelationId( _
   ByVal correlationId As String, _
   ByVal timeout As TimeSpan _
) As Message
'Usage
 
Dim instance As MessageQueue
Dim correlationId As String
Dim timeout As TimeSpan
Dim value As Message
 
value = instance.PeekByCorrelationId(correlationId, timeout)
public Message PeekByCorrelationId( 
   string correlationId,
   TimeSpan timeout
)
public:
Message^ PeekByCorrelationId( 
   String^ correlationId,
   TimeSpan timeout
) 

Parameters

correlationId
The CorrelationId of the message to peek.
timeout
A System.TimeSpan that indicates the time to wait until a new message is available for inspection.

Return Value

The Message whose CorrelationId matches the correlationId parameter passed in.
Exceptions
ExceptionDescription
The correlationId parameter is null.
The value specified for the timeout parameter is not valid, possibly timeout is less than System.TimeSpan.Zero or greater than InfiniteTimeout.
The message with the specified correlationId does not exist in the queue and did not arrive before the time-out expired.
A message did not arrive before the time-out expired.-or- An error occurred when accessing a Message Queuing method.
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

Reference

MessageQueue Class
MessageQueue Members
Overload List