MessageQueue.PeekById 메서드

정의

큐에서 메시지를 제거하지 않고 지정된 메시지 식별자가 있는 메시지의 복사본을 반환합니다.

오버로드

Name Description
PeekById(String)

메시지 식별자가 매개 변수와 일치하는 메시지를 피킹합니다 id .

PeekById(String, TimeSpan)

메시지 식별자가 매개 변수와 일치하는 메시지를 피킹합니다 id . 메시지가 큐에 표시되거나 시간 초과가 발생할 때까지 기다립니다.

PeekById(String)

메시지 식별자가 매개 변수와 일치하는 메시지를 피킹합니다 id .

public:
 System::Messaging::Message ^ PeekById(System::String ^ id);
public System.Messaging.Message PeekById(string id);
member this.PeekById : string -> System.Messaging.Message
Public Function PeekById (id As String) As Message

매개 변수

id
String

Id 피킹할 메시지입니다.

반품

해당 Message 속성이 Id 매개 변수와 일치하는 경우 id

예외

매개 변수는 id .입니다 null.

지정된 id 메시지가 없습니다.

메시지 큐 메서드에 액세스할 때 오류가 발생했습니다.

예제

다음 코드 예제에서는 .의 PeekById(String)사용을 보여 줍니다.


// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

// Create a new message.
Message^ msg = gcnew Message("Example Message Body");

// Send the message.
queue->Send(msg, "Example Message Label");

// Get the message's Id property value.
String^ id = msg->Id;

// Simulate doing other work so the message has time to arrive.
System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0));

// Peek at the message.
msg = queue->PeekById(id);

queue->Close();

// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Create a new message.
Message msg = new Message("Example Message Body");

// Send the message.
queue.Send(msg, "Example Message Label");

// Get the message's Id property value.
string id = msg.Id;

// Simulate doing other work so the message has time to arrive.
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10.0));

// Peek at the message.
msg = queue.PeekById(id);

설명

큐에서 제거하지 않고 알려진 메시지 식별자가 있는 메시지를 읽는 데 사용합니다 PeekById(String) . 메시지의 식별자는 메시지 큐 엔터프라이즈에서 고유하므로 큐에 지정된 id 매개 변수와 일치하는 최대 하나의 메시지가 있습니다. 이 오버로드는 큐에 현재 메시지가 포함되지 않은 경우 예외를 throw합니다.

두 가지 추가 메서드를 사용하면 큐 Peek 의 메시지를 피킹할 수 있습니다 PeekByCorrelationId(String). 이 메서드는 Peek 큐의 첫 번째 메시지를 반환합니다 PeekByCorrelationId(String) . 큐에 전송된 메시지의 결과로 생성된 승인, 보고서 또는 애플리케이션에서 생성된 응답 메시지를 반환합니다.

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 이용 가능
로컬 컴퓨터 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

PeekById(String, TimeSpan)

메시지 식별자가 매개 변수와 일치하는 메시지를 피킹합니다 id . 메시지가 큐에 표시되거나 시간 초과가 발생할 때까지 기다립니다.

public:
 System::Messaging::Message ^ PeekById(System::String ^ id, TimeSpan timeout);
public System.Messaging.Message PeekById(string id, TimeSpan timeout);
member this.PeekById : string * TimeSpan -> System.Messaging.Message
Public Function PeekById (id As String, timeout As TimeSpan) As Message

매개 변수

id
String

Id 피킹할 메시지입니다.

timeout
TimeSpan

새 메시지를 검사할 수 있게 될 때까지 대기하는 시간을 나타내는 A TimeSpan 입니다.

반품

해당 Message 속성이 Id 매개 변수와 일치하는 경우 id

예외

매개 변수는 id .입니다 null.

매개 변수에 timeout 지정된 값이 잘못 timeoutZeroInfiniteTimeout되었습니다.

지정된 id 메시지가 큐에 존재하지 않으며 매개 변수에 지정된 timeout 기간이 만료되기 전에 도착하지 않았습니다.

메시지 큐 메서드에 액세스할 때 오류가 발생했습니다.

예제

다음 코드 예제에서는 .의 PeekById(String, TimeSpan)사용을 보여 줍니다.


// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

// Create a new message.
Message^ msg = gcnew Message("Example Message Body");

// Send the message.
queue->Send(msg, "Example Message Label");

// Get the message's Id property value.
String^ id = msg->Id;

// Peek at the message.
msg = queue->PeekById(id, TimeSpan::FromSeconds(10.0));

queue->Close();

// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Create a new message.
Message msg = new Message("Example Message Body");

// Send the message.
queue.Send(msg, "Example Message Label");

// Get the message's Id property value.
string id = msg.Id;

// Peek at the message.
msg = queue.PeekById(id, TimeSpan.FromSeconds(10.0));

설명

큐에서 제거하지 않고 알려진 메시지 식별자가 있는 메시지를 읽는 데 사용합니다 PeekById(String) . 메시지의 식별자는 메시지 큐 엔터프라이즈에서 고유하므로 큐에 지정된 id 매개 변수와 일치하는 최대 하나의 메시지가 있습니다. 이 오버로드는 큐에 현재 메시지가 포함되어 있지 않고 시간 초과가 발생하기 전에 새 메시지가 도착하지 않는 경우 예외를 throw합니다.

매개 변수는 timeout 이 메서드의 총 실행 시간을 지정하지 않습니다. 대신 새 메시지가 큐에 도착할 때까지 기다리는 시간을 지정합니다. 새 메시지가 도착할 때마다 이 메서드는 새 메시지를 검사 Id 하여 매개 변수와 id 일치하는지 확인합니다. 그렇지 않은 경우 이 메서드는 시간 제한 기간을 시작하고 다른 새 메시지가 도착할 때까지 기다립니다. 따라서 새 메시지가 제한 시간 내에 계속 도착하는 경우 새 메시지가 도착하지 않고 제한 시간이 만료되거나 매개 변수와 일치하는 Id 메시지가 도착할 때까지 이 메서드는 무기한 실행을 계속할 수 있습니다id.

두 가지 추가 메서드를 사용하면 큐 Peek 의 메시지를 피킹할 수 있습니다 PeekByCorrelationId(String). 이 메서드는 Peek 큐의 첫 번째 메시지를 반환합니다 PeekByCorrelationId(String) . 큐에 전송된 메시지의 결과로 생성된 승인, 보고서 또는 애플리케이션에서 생성된 응답 메시지를 반환합니다.

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 이용 가능
로컬 컴퓨터 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상