MessageQueue.GetPublicQueuesByMachine(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 컴퓨터에 있는 공개 큐를 모두 검색합니다.
public:
static cli::array <System::Messaging::MessageQueue ^> ^ GetPublicQueuesByMachine(System::String ^ machineName);
public static System.Messaging.MessageQueue[] GetPublicQueuesByMachine (string machineName);
static member GetPublicQueuesByMachine : string -> System.Messaging.MessageQueue[]
Public Shared Function GetPublicQueuesByMachine (machineName As String) As MessageQueue()
매개 변수
- machineName
- String
검색할 공개 큐 집합을 포함하는 컴퓨터의 이름입니다.
반환
컴퓨터에 있는 공개 큐를 참조하는 MessageQueue 개체의 배열입니다.
예외
machineName
매개 변수의 구문이 잘못되었습니다.
메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우
예제
다음 코드 예제에서는 큐 목록을 검색합니다.
#using <system.dll>
#using <system.messaging.dll>
using namespace System;
using namespace System::Messaging;
using namespace System::Collections;
ref class MyNewQueue
{
public:
// Gets a list of queues with a specified category.
// Sends a broadcast message to all queues in that
// category.
void GetQueuesByCategory()
{
// Get a list of queues with the specified category.
array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByCategory( Guid(" {00000000-0000-0000-0000-000000000001}") );
// Send a broadcast message to each queue in the array.
IEnumerator^ myEnum = QueueList->GetEnumerator();
while ( myEnum->MoveNext() )
{
MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
queueItem->Send( "Broadcast message." );
}
return;
}
// Gets a list of queues with a specified label.
// Sends a broadcast message to all queues with that
// label.
void GetQueuesByLabel()
{
// Get a list of queues with the specified label.
array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByLabel( "My Label" );
// Send a broadcast message to each queue in the array.
IEnumerator^ myEnum = QueueList->GetEnumerator();
while ( myEnum->MoveNext() )
{
MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
queueItem->Send( "Broadcast message." );
}
return;
}
// Gets a list of queues on a specified computer.
// Displays the list on screen.
void GetQueuesByComputer()
{
// Get a list of queues on the specified computer.
array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByMachine( "MyComputer" );
// Display the paths of the queues in the list.
IEnumerator^ myEnum = QueueList->GetEnumerator();
while ( myEnum->MoveNext() )
{
MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
Console::WriteLine( queueItem->Path );
}
return;
}
// Gets a list of all public queues.
void GetAllPublicQueues()
{
// Get a list of public queues.
array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues();
return;
}
// Gets a list of all public queues that match
// specified criteria. Displays the list on
// screen.
void GetPublicQueuesByCriteria()
{
// Define criteria to filter the queues.
MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
myCriteria->ModifiedBefore = DateTime::Now;
myCriteria->MachineName = ".";
myCriteria->Label = "My Queue";
// Get a list of queues with that criteria.
array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues( myCriteria );
// Display the paths of the queues in the list.
IEnumerator^ myEnum = QueueList->GetEnumerator();
while ( myEnum->MoveNext() )
{
MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
Console::WriteLine( queueItem->Path );
}
return;
}
// Gets a list of private queues on the local
// computer. Displays the list on screen.
void GetPrivateQueues()
{
// Get a list of queues with the specified category.
array<MessageQueue^>^QueueList = MessageQueue::GetPrivateQueuesByMachine( "." );
// Display the paths of the queues in the list.
IEnumerator^ myEnum = QueueList->GetEnumerator();
while ( myEnum->MoveNext() )
{
MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
Console::WriteLine( queueItem->Path );
}
return;
}
};
// Provides an entry point into the application.
// This example gets lists of queues by a variety
// of criteria.
int main()
{
// Create a new instance of the class.
MyNewQueue^ myNewQueue = gcnew MyNewQueue;
// Send normal and high priority messages.
myNewQueue->GetQueuesByCategory();
myNewQueue->GetQueuesByLabel();
myNewQueue->GetQueuesByComputer();
myNewQueue->GetAllPublicQueues();
myNewQueue->GetPublicQueuesByCriteria();
myNewQueue->GetPrivateQueues();
return 0;
}
using System;
using System.Messaging;
namespace MyProject
{
/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
//**************************************************
// Provides an entry point into the application.
//
// This example gets lists of queues by a variety
// of criteria.
//**************************************************
public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue();
// Send normal and high priority messages.
myNewQueue.GetQueuesByCategory();
myNewQueue.GetQueuesByLabel();
myNewQueue.GetQueuesByComputer();
myNewQueue.GetAllPublicQueues();
myNewQueue.GetPublicQueuesByCriteria();
myNewQueue.GetPrivateQueues();
return;
}
//**************************************************
// Gets a list of queues with a specified category.
// Sends a broadcast message to all queues in that
// category.
//**************************************************
public void GetQueuesByCategory()
{
// Get a list of queues with the specified category.
MessageQueue[] QueueList =
MessageQueue.GetPublicQueuesByCategory(new
Guid("{00000000-0000-0000-0000-000000000001}"));
// Send a broadcast message to each queue in the array.
foreach(MessageQueue queueItem in QueueList)
{
queueItem.Send("Broadcast message.");
}
return;
}
//**************************************************
// Gets a list of queues with a specified label.
// Sends a broadcast message to all queues with that
// label.
//**************************************************
public void GetQueuesByLabel()
{
// Get a list of queues with the specified label.
MessageQueue[] QueueList =
MessageQueue.GetPublicQueuesByLabel("My Label");
// Send a broadcast message to each queue in the array.
foreach(MessageQueue queueItem in QueueList)
{
queueItem.Send("Broadcast message.");
}
return;
}
//**************************************************
// Gets a list of queues on a specified computer.
// Displays the list on screen.
//**************************************************
public void GetQueuesByComputer()
{
// Get a list of queues on the specified computer.
MessageQueue[] QueueList =
MessageQueue.GetPublicQueuesByMachine("MyComputer");
// Display the paths of the queues in the list.
foreach(MessageQueue queueItem in QueueList)
{
Console.WriteLine(queueItem.Path);
}
return;
}
//**************************************************
// Gets a list of all public queues.
//**************************************************
public void GetAllPublicQueues()
{
// Get a list of public queues.
MessageQueue[] QueueList =
MessageQueue.GetPublicQueues();
return;
}
//**************************************************
// Gets a list of all public queues that match
// specified criteria. Displays the list on
// screen.
//**************************************************
public void GetPublicQueuesByCriteria()
{
// Define criteria to filter the queues.
MessageQueueCriteria myCriteria = new
MessageQueueCriteria();
myCriteria.CreatedAfter = DateTime.Now.Subtract(new
TimeSpan(1,0,0,0));
myCriteria.ModifiedBefore = DateTime.Now;
myCriteria.MachineName = ".";
myCriteria.Label = "My Queue";
// Get a list of queues with that criteria.
MessageQueue[] QueueList =
MessageQueue.GetPublicQueues(myCriteria);
// Display the paths of the queues in the list.
foreach(MessageQueue queueItem in QueueList)
{
Console.WriteLine(queueItem.Path);
}
return;
}
//**************************************************
// Gets a list of private queues on the local
// computer. Displays the list on screen.
//**************************************************
public void GetPrivateQueues()
{
// Get a list of queues with the specified category.
MessageQueue[] QueueList =
MessageQueue.GetPrivateQueuesByMachine(".");
// Display the paths of the queues in the list.
foreach(MessageQueue queueItem in QueueList)
{
Console.WriteLine(queueItem.Path);
}
return;
}
}
}
Imports System.Messaging
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example gets lists of queues by a variety
' of criteria.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Send normal and high priority messages.
myNewQueue.GetQueuesByCategory()
myNewQueue.GetQueuesByLabel()
myNewQueue.GetQueuesByComputer()
myNewQueue.GetAllPublicQueues()
myNewQueue.GetPublicQueuesByCriteria()
myNewQueue.GetPrivateQueues()
Return
End Sub
' Gets a list of queues with a specified category.
' Sends a broadcast message to all queues in that
' category.
Public Sub GetQueuesByCategory()
' Get a list of queues with the specified category.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPublicQueuesByCategory(New _
Guid("{00000000-0000-0000-0000-000000000001}"))
' Send a broadcast message to each queue in the array.
Dim queueItem As MessageQueue
For Each queueItem In QueueList
queueItem.Send("Broadcast message.")
Next queueItem
Return
End Sub
' Gets a list of queues with a specified label.
' Sends a broadcast message to all queues with that
' label.
Public Sub GetQueuesByLabel()
' Get a list of queues with the specified label.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPublicQueuesByLabel("My Label")
' Send a broadcast message to each queue in the array.
Dim queueItem As MessageQueue
For Each queueItem In QueueList
queueItem.Send("Broadcast message.")
Next queueItem
Return
End Sub
' Gets a list of queues on a specified computer.
' Displays the list on screen.
Public Sub GetQueuesByComputer()
' Get a list of queues on the specified computer.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPublicQueuesByMachine("MyComputer")
' Display the paths of the queues in the list.
Dim queueItem As MessageQueue
For Each queueItem In QueueList
Console.WriteLine(queueItem.Path)
Next queueItem
Return
End Sub
' Gets a list of all public queues.
Public Sub GetAllPublicQueues()
' Get a list of public queues.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPublicQueues()
Return
End Sub
' Gets a list of all public queues that match
' specified criteria. Displays the list on
' screen.
Public Sub GetPublicQueuesByCriteria()
' Define criteria to filter the queues.
Dim myCriteria As New MessageQueueCriteria()
myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
TimeSpan(1, 0, 0, 0))
myCriteria.ModifiedBefore = DateTime.Now
myCriteria.MachineName = "."
myCriteria.Label = "My Queue"
' Get a list of queues with that criteria.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPublicQueues(myCriteria)
' Display the paths of the queues in the list.
Dim queueItem As MessageQueue
For Each queueItem In QueueList
Console.WriteLine(queueItem.Path)
Next queueItem
Return
End Sub
' Gets a list of private queues on the local
' computer. Displays the list on screen.
Public Sub GetPrivateQueues()
' Get a list of queues with the specified category.
Dim QueueList As MessageQueue() = _
MessageQueue.GetPrivateQueuesByMachine(".")
' Display the paths of the queues in the list.
Dim queueItem As MessageQueue
For Each queueItem In QueueList
Console.WriteLine(queueItem.Path)
Next queueItem
Return
End Sub
End Class
설명
이 메서드를 사용하여 컴퓨터별로 공용 큐를 필터링합니다.
GetPublicQueuesByMachine(String)는 큐의 정적 스냅샷 검색합니다. 큐의 동적 목록과 상호 작용하려면 를 사용합니다 GetMessageQueueEnumerator. 메서드에 전달하는 의 MessageQueueCriteria 일부로 컴퓨터 이름을 지정할 수 있습니다.
다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.
작업 그룹 모드 | 사용 가능 |
---|---|
수집 | No |
로컬 컴퓨터 및 직접 형식 이름 | No |
원격 컴퓨터 | No |
원격 컴퓨터 및 직접 형식 이름 | No |
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET