MessageQueue.GetPublicQueues 메서드

정의

네트워크에 있는 공개 큐를 모두 검색합니다.

오버로드

GetPublicQueues()

네트워크에 있는 공개 큐를 모두 검색합니다.

GetPublicQueues(MessageQueueCriteria)

네트워크에 있는 공개 큐 중 지정된 기준을 만족시키는 큐를 모두 검색합니다.

GetPublicQueues()

네트워크에 있는 공개 큐를 모두 검색합니다.

C#
public static System.Messaging.MessageQueue[] GetPublicQueues ();

반환

검색된 공개 큐를 참조하는 MessageQueue 개체의 배열입니다.

예외

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 큐 목록을 검색합니다.

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;
        }
    }
}

설명

네트워크에 있는 모든 공용 큐의 전체 목록을 원하는 경우 이 오버로드를 사용합니다. , , Category또는 마지막으로 수정한 시간과 같은 MachineName특정 조건으로 목록을 제한하려면 이 메서드의 다른 오버로드를 사용합니다. 또는 , 또는 GetPublicQueuesByLabel(String)GetPublicQueuesByCategory(Guid)사용할 GetPublicQueuesByMachine(String)수 있습니다.

GetPublicQueues는 큐의 정적 스냅샷 검색합니다. 큐의 동적 목록과 상호 작용하려면 를 사용합니다 GetMessageQueueEnumerator.

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

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

추가 정보

적용 대상

.NET Framework 4.8.1 및 기타 버전
제품 버전
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

GetPublicQueues(MessageQueueCriteria)

네트워크에 있는 공개 큐 중 지정된 기준을 만족시키는 큐를 모두 검색합니다.

C#
public static System.Messaging.MessageQueue[] GetPublicQueues (System.Messaging.MessageQueueCriteria criteria);

매개 변수

criteria
MessageQueueCriteria

큐를 필터링하는 데 사용되는 기준이 포함된 MessageQueueCriteria입니다.

반환

검색된 공개 큐를 참조하는 MessageQueue 개체의 배열입니다.

예외

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 큐 목록을 검색합니다.

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;
        }
    }
}

설명

레이블, 범주 또는 컴퓨터 이름을 MessageQueue 기준으로 네트워크의 모든 공용 큐를 필터링하려는 경우 클래스에는 해당 기능(GetPublicQueuesByLabel(String)각각 , GetPublicQueuesByCategory(Guid)GetPublicQueuesByMachine(String))을 제공하는 특정 메서드가 포함됩니다. 이 오버로드를 사용하여 이러한 조건 중 하나 이상을 충족하는 네트워크의 모든 공용 큐 목록을 가져옵니다(예: 레이블과 범주를 모두 지정하려는 경우). , 및 이외의 Label메시지 조건을 기준으로 필터링할 수도 있습니다MachineName. Category 예를 들어 이 오버로드를 사용하여 큐의 마지막 수정 시간을 기준으로 필터링합니다. 클래스의 MessageQueueCriteria 새 instance 만들고, instance 적절한 속성을 설정하고, instance 매개 변수로 criteria 전달하기만 하면 됩니다.

GetPublicQueues는 큐의 정적 스냅샷 검색합니다. 큐의 동적 목록과 상호 작용하려면 를 사용합니다 GetMessageQueueEnumerator.

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

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

추가 정보

적용 대상

.NET Framework 4.8.1 및 기타 버전
제품 버전
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1