AcknowledgeTypes 열거형

정의

메시지 큐에서 보내는 애플리케이션으로 반환하는 승인 메시지의 형식을 지정합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class AcknowledgeTypes
[System.Flags]
public enum AcknowledgeTypes
[<System.Flags>]
type AcknowledgeTypes = 
Public Enum AcknowledgeTypes
상속
AcknowledgeTypes
특성

필드

FullReachQueue 5

원본 메시지가 큐에 도착할 경우 긍정 승인을 요청하거나 큐 도착 시간 타이머가 만료될 경우 또는 원본 메시지가 인증되지 않을 경우 부정 승인을 요청하는 데 사용되는 마스크입니다.

FullReceive 14

받을 시간 타이머가 만료되기 전에 큐로부터 원본 메시지를 받는 경우 긍정 승인을 요청하거나 그렇지 않은 경우 부정 승인을 요청하는 데 사용되는 마스크입니다.

NegativeReceive 8

큐로부터 원본 메시지를 받지 못할 경우 부정 승인을 요청하는 데 사용되는 마스크입니다.

사용 하 여 MessageQueue.Peek 메서드 제거 하지 않습니다는 메시지 큐에서 메시지를 피킹 하는 경우에이 승인 유형을 반환 될 수 있도록 합니다. 만 MessageQueue.Receive 메서드 (또는 관련 비동기 MessageQueue.BeginReceive 메서드) 메시지를 큐에서 제거 합니다.

None 0

긍정 승인 메시지나 부정 승인 메시지를 게시하지 않도록 요청하는 데 사용되는 마스크입니다.

NotAcknowledgeReachQueue 4

원본 메시지가 큐에 도착하지 못하는 경우 부정 승인을 요청하는 데 사용되는 마스크입니다. 큐 도착 시간 타이머가 만료되거나 메시지가 인증되지 않을 경우 발생합니다.

NotAcknowledgeReceive 12

받을 시간 타이머가 만료되기 전에 큐로부터 원본 메시지를 받을 수 없는 오류가 발생한 경우 부정 승인을 요청하는 데 사용되는 마스크입니다.

PositiveArrival 1

원본 메시지가 큐에 도착할 경우 긍정 승인을 요청하는 데 사용되는 마스크입니다.

PositiveReceive 2

큐에서 원본 메시지가 성공적으로 검색될 경우 긍정 승인을 요청하는 데 사용되는 마스크입니다.

예제

다음 코드 예제에서는 큐에서 주문을 포함 하는 메시지를 송수신 설정 합니다. 원본 메시지가 도달 하거나이 특히 긍정 승인을 요청 큐에서 검색 합니다.

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:
   static void CreateQueue( String^ queuePath )
   {
      try
      {
         if (  !MessageQueue::Exists( queuePath ) )
         {
            MessageQueue::Create( queuePath );
         }
         else
         {
            Console::WriteLine(  "{0} already exists.", queuePath );
         }
      }
      catch ( MessageQueueException^ e ) 
      {
         Console::WriteLine( e->Message );
      }

   }

   void SendMessage()
   {
      // Connect to a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Create a new message.
      Message^ myMessage = gcnew Message( "Original Message" );
      myMessage->AdministrationQueue = gcnew MessageQueue( ".\\myAdministrationQueue" );
      myMessage->AcknowledgeType = (AcknowledgeTypes)(AcknowledgeTypes::PositiveReceive | AcknowledgeTypes::PositiveArrival);

      // Send the Order to the queue.
      myQueue->Send( myMessage );
      return;
   }

   String^ ReceiveMessage()
   {
      // Connect to the a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
      myQueue->MessageReadPropertyFilter->CorrelationId = true;
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = String::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );
      String^ returnString = nullptr;
      try
      {
         // Receive and format the message. 
         Message^ myMessage = myQueue->Receive();

         // Display message information.
         Console::WriteLine( "____________________________________________" );
         Console::WriteLine( "Original message information--" );
         Console::WriteLine( "Body: {0}", myMessage->Body );
         Console::WriteLine( "Id: {0}", myMessage->Id );
         Console::WriteLine( "____________________________________________" );
         returnString = myMessage->Id;
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle Message Queuing exceptions.
      }
      // Handle invalid serialization format.
      catch ( InvalidOperationException^ e ) 
      {
         Console::WriteLine( e->Message );
      }

      // Catch other exceptions as necessary.
      return returnString;
   }

   void ReceiveAcknowledgment( String^ messageId, String^ queuePath )
   {
      bool found = false;
      MessageQueue^ queue = gcnew MessageQueue( queuePath );
      queue->MessageReadPropertyFilter->CorrelationId = true;
      queue->MessageReadPropertyFilter->Acknowledgment = true;
      try
      {
         while ( queue->PeekByCorrelationId( messageId ) != nullptr )
         {
            Message^ myAcknowledgmentMessage = queue->ReceiveByCorrelationId( messageId );

            // Output acknowledgment message information. The correlation Id is identical
            // to the id of the original message.
            Console::WriteLine( "Acknowledgment Message Information--" );
            Console::WriteLine( "Correlation Id: {0}", myAcknowledgmentMessage->CorrelationId );
            Console::WriteLine( "Id: {0}", myAcknowledgmentMessage->Id );
            Console::WriteLine( "Acknowledgment Type: {0}", myAcknowledgmentMessage->Acknowledgment );
            Console::WriteLine( "____________________________________________" );
            found = true;
         }
      }
      catch ( InvalidOperationException^ e ) 
      {
         // This exception would be thrown if there is no (further) acknowledgment message
         // with the specified correlation Id. Only output a message if there are no messages;
         // not if the loop has found at least one.
         if ( found == false )
         {
            Console::WriteLine( e->Message );
         }

         // Handle other causes of invalid operation exception.
      }

   }

};

int main()
{
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;

   // Create new queues.
   MyNewQueue::CreateQueue( ".\\myQueue" );
   MyNewQueue::CreateQueue( ".\\myAdministrationQueue" );

   // Send messages to a queue.
   myNewQueue->SendMessage();

   // Receive messages from a queue.
   String^ messageId = myNewQueue->ReceiveMessage();

   // Receive acknowledgment message.
   if ( messageId != nullptr )
   {
      myNewQueue->ReceiveAcknowledgment( messageId, ".\\myAdministrationQueue" );
   }

   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 sends and receives a message from
        // a queue.
        //**************************************************

        public static void Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Create new queues.
            CreateQueue(".\\myQueue");
            CreateQueue(".\\myAdministrationQueue");

            // Send messages to a queue.
            myNewQueue.SendMessage();

            // Receive messages from a queue.
            string messageId = myNewQueue.ReceiveMessage();

            // Receive acknowledgment message.
            if(messageId != null)
            {
                myNewQueue.ReceiveAcknowledgment(messageId, ".\\myAdministrationQueue");
            }

            return;
        }

        //**************************************************
        // Creates a new queue.
        //**************************************************

        public static void CreateQueue(string queuePath)
        {
            try	
            {
                if(!MessageQueue.Exists(queuePath))
                {
                    MessageQueue.Create(queuePath);
                }
                else
                {
                    Console.WriteLine(queuePath + " already exists.");
                }
            }
            catch (MessageQueueException e)
            {
                Console.WriteLine(e.Message);
            }
        }

        //**************************************************
        // Sends a string message to a queue.
        //**************************************************
        
        public void SendMessage()
        {

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

            // Create a new message.
            Message myMessage = new Message("Original Message");

            myMessage.AdministrationQueue = new MessageQueue(".\\myAdministrationQueue");
            myMessage.AcknowledgeType = AcknowledgeTypes.PositiveReceive | AcknowledgeTypes.PositiveArrival;

            // Send the Order to the queue.
            myQueue.Send(myMessage);

            return;
        }

        //**************************************************
        // Receives a message containing an Order.
        //**************************************************
        
        public  string ReceiveMessage()
        {
            // Connect to the a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            myQueue.MessageReadPropertyFilter.CorrelationId = true;

            // Set the formatter to indicate body contains an Order.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(string)});

            string returnString = null;
            
            try
            {
                // Receive and format the message.
                Message myMessage =	myQueue.Receive();

                // Display message information.
                Console.WriteLine("____________________________________________");
                Console.WriteLine("Original message information--");
                Console.WriteLine("Body: " +myMessage.Body.ToString());
                Console.WriteLine("Id: " + myMessage.Id.ToString());
                Console.WriteLine("____________________________________________");

                returnString =  myMessage.Id;
            }
            
            catch (MessageQueueException)
            {
                // Handle Message Queuing exceptions.
            }

            // Handle invalid serialization format.
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.Message);
            }
            
            // Catch other exceptions as necessary.

            return returnString;
        }

        //**************************************************
        // Receives a message containing an Order.
        //**************************************************
        
        public void ReceiveAcknowledgment(string messageId, string queuePath)
        {
            bool found = false;
            MessageQueue queue = new MessageQueue(queuePath);
            queue.MessageReadPropertyFilter.CorrelationId = true;
            queue.MessageReadPropertyFilter.Acknowledgment = true;

            try
            {
                while(queue.PeekByCorrelationId(messageId) != null)
                {
                    Message myAcknowledgmentMessage = queue.ReceiveByCorrelationId(messageId);
            
                    // Output acknowledgment message information. The correlation Id is identical
                    // to the id of the original message.
                    Console.WriteLine("Acknowledgment Message Information--");
                    Console.WriteLine("Correlation Id: " + myAcknowledgmentMessage.CorrelationId.ToString());
                    Console.WriteLine("Id: " + myAcknowledgmentMessage.Id.ToString());
                    Console.WriteLine("Acknowledgment Type: " + myAcknowledgmentMessage.Acknowledgment.ToString());
                    Console.WriteLine("____________________________________________");

                    found = true;
                }
            }
            catch (InvalidOperationException e)
            {
                // This exception would be thrown if there is no (further) acknowledgment message
                // with the specified correlation Id. Only output a message if there are no messages;
                // not if the loop has found at least one.
                if(found == false)
                {	
                    Console.WriteLine(e.Message);
                }

                // Handle other causes of invalid operation exception.
            }
        }
    }
}
Imports System.Messaging


' Provides a container class for the example.

Public Class MyNewQueue
   
   

   ' Provides an entry point into the application.       
   ' This example sends and receives a message from
   ' a queue.
      
   Public Shared Sub Main()
         ' Create a new instance of the class.
         Dim myNewQueue As New MyNewQueue()
         
         ' Create new queues.
         CreateQueue(".\myQueue")
         CreateQueue(".\myAdministrationQueue")
         
         ' Send messages to a queue.
         myNewQueue.SendMessage()
         
         ' Receive messages from a queue.
         Dim messageId As String = myNewQueue.ReceiveMessage()
         
         ' Receive acknowledgment message.
         If Not (messageId Is Nothing) Then
            myNewQueue.ReceiveAcknowledgment(messageId, ".\myAdministrationQueue")
         End If
         
         Return
   End Sub
      
      
      ' Creates a new queue.

   Public Shared Sub CreateQueue(queuePath As String)
         Try
            If Not MessageQueue.Exists(queuePath) Then
               MessageQueue.Create(queuePath)
            Else
               Console.WriteLine((queuePath + " already exists."))
            End If
         Catch e As MessageQueueException
            Console.WriteLine(e.Message)
         End Try
   End Sub
       
      
      
 
      ' Sends a string message to a queue.
 
   Public Sub SendMessage()
         
         ' Connect to a queue on the local computer.
         Dim myQueue As New MessageQueue(".\myQueue")
         
         ' Create a new message.
         Dim myMessage As New Message("Original Message")
         
         myMessage.AdministrationQueue = New MessageQueue(".\myAdministrationQueue")
         myMessage.AcknowledgeType = AcknowledgeTypes.PositiveReceive Or AcknowledgeTypes.PositiveArrival
         
         ' Send the Order to the queue.
         myQueue.Send(myMessage)
         
         Return
   End Sub
      
      
      
 
      ' Receives a message containing an Order.
 
   Public Function ReceiveMessage() As String
         ' Connect to the a queue on the local computer.
         Dim myQueue As New MessageQueue(".\myQueue")
         
         myQueue.MessageReadPropertyFilter.CorrelationId = True
         
         
         ' Set the formatter to indicate body contains an Order.
         myQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(String)})
         
         Dim returnString As String = Nothing
         
         Try
            ' Receive and format the message. 
            Dim myMessage As Message = myQueue.Receive()
            
            
            ' Display message information.
            Console.WriteLine("____________________________________________")
            Console.WriteLine("Original message information--")
            Console.WriteLine(("Body: " + myMessage.Body.ToString()))
            Console.WriteLine(("Id: " + myMessage.Id.ToString()))
            Console.WriteLine("____________________________________________")
            
            returnString = myMessage.Id
         
         
                  
         ' Handle invalid serialization format.
         Catch e As InvalidOperationException
            Console.WriteLine(e.Message)
         End Try
         
         ' Catch other exceptions as necessary.
         Return returnString
   End Function 'ReceiveMessage
      
      
 
      ' Receives a message containing an Order.
 
   Public Sub ReceiveAcknowledgment(messageId As String, queuePath As String)
         Dim found As Boolean = False
         Dim queue As New MessageQueue(queuePath)
         queue.MessageReadPropertyFilter.CorrelationId = True
         queue.MessageReadPropertyFilter.Acknowledgment = True
         
         Try
            While Not (queue.PeekByCorrelationId(messageId) Is Nothing)
               Dim myAcknowledgmentMessage As Message = queue.ReceiveByCorrelationId(messageId)
               
               ' Output acknowledgment message information. The correlation Id is identical
               ' to the id of the original message.
               Console.WriteLine("Acknowledgment Message Information--")
               Console.WriteLine(("Correlation Id: " + myAcknowledgmentMessage.CorrelationId.ToString()))
               Console.WriteLine(("Id: " + myAcknowledgmentMessage.Id.ToString()))
               Console.WriteLine(("Acknowledgment Type: " + myAcknowledgmentMessage.Acknowledgment.ToString()))
               Console.WriteLine("____________________________________________")
               
               found = True
            End While
         Catch e As InvalidOperationException
            ' This exception would be thrown if there is no (further) acknowledgment message
            ' with the specified correlation Id. Only output a message if there are no messages;
            ' not if the loop has found at least one.
            If found = False Then
               Console.WriteLine(e.Message)
            End If
         End Try 
   End Sub
 End Class

설명

AcknowledgeTypes 클래스 요청 승인 메시지의 하나 이상의 범주를 조합할 수 있는 플래그 집합을 제공 합니다.

애플리케이션 메시지를 보내면 메시지 큐 원본 메시지의 성공 여부를 나타내는 승인 메시지를 반환 하도록 요청할 수 있습니다. 메시지 큐는 지정한 관리 큐에 이러한 승인 메시지를 보냅니다. 승인 형식 4 개 그룹으로 광범위 하 게 나눌 수 있습니다: 긍정 도착 승인, 긍정 읽기 승인, 부정 도착 승인 및 부정 읽기 승인입니다. 승인을 요청하면 애플리케이션이 특정 항목에 대한 알림을 받을 수 있습니다(예: 대상 큐에 도달하는 메시지, 검색되는 메시지 또는 메시지 도달 또는 대상 큐에서 검색되지 않도록 하는 시간 제한).

사용 하는 경우는 Message 큐에 메시지를 보낼 클래스, 애플리케이션에서 수신 해야 하는 승인의 형식을 지정할는 AcknowledgeType 에서 승인 메시지를 수신 하는 관리 큐 뿐만 아니라 속성에는 AdministrationQueue 속성입니다.

사용 하는 경우는 Message 클래스는 관리 큐의 인스턴스가 승인 메시지를 읽을 Acknowledgment 속성 조건을 나타냅니다 승인 메시지 작업을 담당 합니다. 예를 들어, 제한 시간이 만료 되기 전에 큐에서 원래 메시지를 읽었습니다.

적용 대상

추가 정보