MessageQueue.GetPublicQueues メソッド (MessageQueueCriteria)
指定した基準を満たすネットワーク上のすべてのパブリック キューを取得します。
Overloads Public Shared Function GetOverloads PublicQueues( _
ByVal criteria As MessageQueueCriteria _) As MessageQueue()
[C#]
public static MessageQueue[] GetPublicQueues(MessageQueueCriteriacriteria);
[C++]
public: static MessageQueue* GetPublicQueues(MessageQueueCriteria* criteria) [];
[JScript]
public static function GetPublicQueues(
criteria : MessageQueueCriteria) : MessageQueue[];
パラメータ
- criteria
キューのフィルタ処理に使用する基準が格納されている MessageQueueCriteria 。
戻り値
取得したパブリック キューを参照する MessageQueue オブジェクトの配列。
例外
例外の種類 | 条件 |
---|---|
MessageQueueException | メッセージ キューの API にアクセスしたときにエラーが発生しました。 |
解説
ネットワーク上のすべてのパブリック キューを、ラベル、カテゴリ、またはコンピュータ名でフィルタ処理する場合は、該当する機能を提供する特定のメソッド (それぞれ GetPublicQueuesByLabel 、 GetPublicQueuesByCategory 、 GetPublicQueuesByMachine) が MessageQueue クラスに含まれています。このオーバーロードは、これらの基準のうち複数を満たすネットワーク上のすべてのパブリック キューのリストを取得するときに使用します (ラベルとカテゴリの両方を指定するなど)。 Label 、 Category 、および MachineName 以外のメッセージの基準でもフィルタ処理できます。たとえば、このオーバーロードを使用して、キューの最終変更時刻でフィルタ処理できます。 MessageQueueCriteria クラスの新しいインスタンスを作成し、適切なプロパティをインスタンスに設定し、インスタンスを criteria パラメータとして渡すだけです。
GetPublicQueues は、キューの静的スナップショットを取得します。キューの動的なリストと対話するには、 GetMessageQueueEnumerator を使用します。
このメソッドが各種のワークグループ モードで使用できるかどうかを次の表に示します。
ワークグループ モード | 使用可否 |
---|---|
ローカル コンピュータ | いいえ |
ローカル コンピュータ + 直接書式名 | いいえ |
リモート コンピュータ | いいえ |
リモート コンピュータ + 直接書式名 | いいえ |
使用例
[Visual Basic, C#, C++] キューの一覧を取得する例を次に示します。
Imports System
Imports 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 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 'Main
'**************************************************
' 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 'GetQueuesByCategory
'**************************************************
' 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 'GetQueuesByLabel
'**************************************************
' 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 'GetQueuesByComputer
'**************************************************
' 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 'GetAllPublicQueues
'**************************************************
' 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 'GetPublicQueuesByCriteria
'**************************************************
' 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 'GetPrivateQueues
End Class 'MyNewQueue
End Namespace 'MyProject
[C#]
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;
}
}
}
[C++]
#using <mscorlib.dll>
#using <system.dll>
#using <system.messaging.dll>
using namespace System;
using namespace System::Messaging;
using namespace System::Collections;
__gc class MyNewQueue
{
// 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(
Guid(S" {00000000-0000-0000-0000-000000000001}"));
// Send a broadcast message to each queue in the array.
IEnumerator* myEnum = QueueList->GetEnumerator();
while (myEnum->MoveNext())
{
MessageQueue* queueItem = __try_cast<MessageQueue*>(myEnum->Current);
queueItem->Send(S"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(S"My Label");
// Send a broadcast message to each queue in the array.
IEnumerator* myEnum = QueueList->GetEnumerator();
while (myEnum->MoveNext())
{
MessageQueue* queueItem = __try_cast<MessageQueue*>(myEnum->Current);
queueItem->Send(S"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(S"MyComputer");
// Display the paths of the queues in the list.
IEnumerator* myEnum = QueueList->GetEnumerator();
while (myEnum->MoveNext())
{
MessageQueue* queueItem = __try_cast<MessageQueue*>(myEnum->Current);
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(TimeSpan(1, 0, 0, 0));
myCriteria->ModifiedBefore = DateTime::Now;
myCriteria->MachineName = S".";
myCriteria->Label = S"My Queue";
// Get a list of queues with that criteria.
MessageQueue* QueueList[] =
MessageQueue::GetPublicQueues(myCriteria);
// Display the paths of the queues in the list.
IEnumerator* myEnum = QueueList->GetEnumerator();
while (myEnum->MoveNext())
{
MessageQueue* queueItem = __try_cast<MessageQueue*>(myEnum->Current);
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(S".");
// Display the paths of the queues in the list.
IEnumerator* myEnum = QueueList->GetEnumerator();
while (myEnum->MoveNext())
{
MessageQueue* queueItem = __try_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 = new MyNewQueue();
// Send normal and high priority messages.
myNewQueue->GetQueuesByCategory();
myNewQueue->GetQueuesByLabel();
myNewQueue->GetQueuesByComputer();
myNewQueue->GetAllPublicQueues();
myNewQueue->GetPublicQueuesByCriteria();
myNewQueue->GetPrivateQueues();
return 0;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
MessageQueue クラス | MessageQueue メンバ | System.Messaging 名前空間 | MessageQueue.GetPublicQueues オーバーロードの一覧 | MessageQueueCriteria | GetPublicQueuesByCategory | GetPublicQueuesByLabel | GetPublicQueuesByMachine | GetMessageQueueEnumerator | GetPrivateQueuesByMachine