MessageQueue 類別

定義

提供 Message Queuing 伺服器上的佇列存取。

public ref class MessageQueue : System::ComponentModel::Component, System::Collections::IEnumerable
[System.ComponentModel.TypeConverter(typeof(System.Messaging.Design.MessageQueueConverter))]
public class MessageQueue : System.ComponentModel.Component, System.Collections.IEnumerable
[System.ComponentModel.TypeConverter(typeof(System.Messaging.Design.MessageQueueConverter))]
[System.Messaging.MessagingDescription("MessageQueueDesc")]
public class MessageQueue : System.ComponentModel.Component, System.Collections.IEnumerable
[<System.ComponentModel.TypeConverter(typeof(System.Messaging.Design.MessageQueueConverter))>]
type MessageQueue = class
    inherit Component
    interface IEnumerable
[<System.ComponentModel.TypeConverter(typeof(System.Messaging.Design.MessageQueueConverter))>]
[<System.Messaging.MessagingDescription("MessageQueueDesc")>]
type MessageQueue = class
    inherit Component
    interface IEnumerable
Public Class MessageQueue
Inherits Component
Implements IEnumerable
繼承
屬性
實作

範例

下列程式碼範例會使用各種路徑名稱語法類型來建立新的 MessageQueue 物件。 在每個案例中,它會將訊息傳送至佇列,其路徑定義于建構函式中。

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

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // References public queues.
   void SendPublic()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
      myQueue->Send( "Public queue by path name." );
      return;
   }


   // References private queues.
   void SendPrivate()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\Private$\\myQueue" );
      myQueue->Send( "Private queue by path name." );
      return;
   }


   // References queues by label.
   void SendByLabel()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "Label:TheLabel" );
      myQueue->Send( "Queue by label." );
      return;
   }


   // References queues by format name.
   void SendByFormatName()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "FormatName:Public=5A5F7535-AE9A-41d4 -935C-845C2AFF7112" );
      myQueue->Send( "Queue by format name." );
      return;
   }


   // References computer journal queues.
   void MonitorComputerJournal()
   {
      MessageQueue^ computerJournal = gcnew MessageQueue( ".\\Journal$" );
      while ( true )
      {
         Message^ journalMessage = computerJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References queue journal queues.
   void MonitorQueueJournal()
   {
      MessageQueue^ queueJournal = gcnew MessageQueue( ".\\myQueue\\Journal$" );
      while ( true )
      {
         Message^ journalMessage = queueJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References dead-letter queues.
   void MonitorDeadLetter()
   {
      MessageQueue^ deadLetter = gcnew MessageQueue( ".\\DeadLetter$" );
      while ( true )
      {
         Message^ deadMessage = deadLetter->Receive();
         
         // Process the dead-letter message.
      }
   }


   // References transactional dead-letter queues.
   void MonitorTransactionalDeadLetter()
   {
      MessageQueue^ TxDeadLetter = gcnew MessageQueue( ".\\XactDeadLetter$" );
      while ( true )
      {
         Message^ txDeadLetter = TxDeadLetter->Receive();
         
         // Process the transactional dead-letter message.
      }
   }

};


//*************************************************
// Provides an entry point into the application.
//         
// This example demonstrates several ways to set
// a queue's path.
//*************************************************
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   myNewQueue->SendPublic();
   myNewQueue->SendPrivate();
   myNewQueue->SendByLabel();
   myNewQueue->SendByFormatName();
   myNewQueue->MonitorComputerJournal();
   myNewQueue->MonitorQueueJournal();
   myNewQueue->MonitorDeadLetter();
   myNewQueue->MonitorTransactionalDeadLetter();
   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 demonstrates several ways to set
        // a queue's path.
        //**************************************************

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

            myNewQueue.SendPublic();
            myNewQueue.SendPrivate();
            myNewQueue.SendByLabel();
            myNewQueue.SendByFormatName();
            myNewQueue.MonitorComputerJournal();
            myNewQueue.MonitorQueueJournal();
            myNewQueue.MonitorDeadLetter();
            myNewQueue.MonitorTransactionalDeadLetter();

            return;
        }
        
        // References public queues.
        public void SendPublic()
        {
            MessageQueue myQueue = new MessageQueue(".\\myQueue");
            myQueue.Send("Public queue by path name.");

            return;
        }

        // References private queues.
        public void SendPrivate()
        {
            MessageQueue myQueue = new
                MessageQueue(".\\Private$\\myQueue");
            myQueue.Send("Private queue by path name.");

            return;
        }

        // References queues by label.
        public void SendByLabel()
        {
            MessageQueue myQueue = new MessageQueue("Label:TheLabel");
            myQueue.Send("Queue by label.");

            return;
        }

        // References queues by format name.
        public void SendByFormatName()
        {
            MessageQueue myQueue = new
                MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" +
                "-935C-845C2AFF7112");
            myQueue.Send("Queue by format name.");

            return;
        }

        // References computer journal queues.
        public void MonitorComputerJournal()
        {
            MessageQueue computerJournal = new
                MessageQueue(".\\Journal$");
            while(true)
            {
                Message journalMessage = computerJournal.Receive();
                // Process the journal message.
            }
        }

        // References queue journal queues.
        public void MonitorQueueJournal()
        {
            MessageQueue queueJournal = new
                MessageQueue(".\\myQueue\\Journal$");
            while(true)
            {
                Message journalMessage = queueJournal.Receive();
                // Process the journal message.
            }
        }
        
        // References dead-letter queues.
        public void MonitorDeadLetter()
        {
            MessageQueue deadLetter = new
                MessageQueue(".\\DeadLetter$");
            while(true)
            {
                Message deadMessage = deadLetter.Receive();
                // Process the dead-letter message.
            }
        }

        // References transactional dead-letter queues.
        public void MonitorTransactionalDeadLetter()
        {
            MessageQueue TxDeadLetter = new
                MessageQueue(".\\XactDeadLetter$");
            while(true)
            {
                Message txDeadLetter = TxDeadLetter.Receive();
                // Process the transactional dead-letter message.
            }
        }
    }
}
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example demonstrates several ways to set
        ' a queue's path.
        

        Public Shared Sub Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New MyNewQueue()

            myNewQueue.SendPublic()
            myNewQueue.SendPrivate()
            myNewQueue.SendByLabel()
            myNewQueue.SendByFormatName()
            myNewQueue.MonitorComputerJournal()
            myNewQueue.MonitorQueueJournal()
            myNewQueue.MonitorDeadLetter()
            myNewQueue.MonitorTransactionalDeadLetter()

            Return

        End Sub


        ' References public queues.
        Public Sub SendPublic()

            Dim myQueue As New MessageQueue(".\myQueue")
            myQueue.Send("Public queue by path name.")

            Return

        End Sub


        ' References private queues.
        Public Sub SendPrivate()

            Dim myQueue As New MessageQueue(".\Private$\myQueue")
            myQueue.Send("Private queue by path name.")

            Return

        End Sub


        ' References queues by label.
        Public Sub SendByLabel()

            Dim myQueue As New MessageQueue("Label:TheLabel")
            myQueue.Send("Queue by label.")

            Return

        End Sub


        ' References queues by format name.
        Public Sub SendByFormatName()

            Dim myQueue As New _
                MessageQueue("FormatName:Public=" + _
                    "5A5F7535-AE9A-41d4-935C-845C2AFF7112")
            myQueue.Send("Queue by format name.")

            Return

        End Sub


        ' References computer journal queues.
        Public Sub MonitorComputerJournal()

            Dim computerJournal As New MessageQueue(".\Journal$")

            While True

                Dim journalMessage As Message = _
                    computerJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub


        ' References queue journal queues.
        Public Sub MonitorQueueJournal()

            Dim queueJournal As New _
                            MessageQueue(".\myQueue\Journal$")

            While True

                Dim journalMessage As Message = _
                    queueJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub


        ' References dead-letter queues.
        Public Sub MonitorDeadLetter()
            Dim deadLetter As New MessageQueue(".\DeadLetter$")

            While True

                Dim deadMessage As Message = deadLetter.Receive()

                ' Process the dead-letter message.

            End While

            Return

        End Sub


        ' References transactional dead-letter queues.
        Public Sub MonitorTransactionalDeadLetter()

            Dim TxDeadLetter As New MessageQueue(".\XactDeadLetter$")

            While True

                Dim txDeadLetterMessage As Message = _
                    TxDeadLetter.Receive()

                ' Process the transactional dead-letter message.

            End While

            Return

        End Sub

End Class

下列程式碼範例會使用名為 Order 的應用程式特定類別,將訊息傳送至佇列,並從佇列接收訊息。

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

using namespace System;
using namespace System::Messaging;

// This class represents an object the following example 
// sends to a queue and receives from a queue.
ref class Order
{
public:
   int orderId;
   DateTime orderTime;
};


/// <summary>
/// Provides a container class for the example.
/// </summary>
ref class MyNewQueue
{
public:

   //*************************************************
   // Sends an Order to a queue.
   //*************************************************
   void SendMessage()
   {
      // Create a new order and set values.
      Order^ sentOrder = gcnew Order;
      sentOrder->orderId = 3;
      sentOrder->orderTime = DateTime::Now;

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

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

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

      // Set the formatter to indicate body contains an Order.
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = Order::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );
      try
      {
         // Receive and format the message. 
         Message^ myMessage = myQueue->Receive();
         Order^ myOrder = static_cast<Order^>(myMessage->Body);

         // Display message information.
         Console::WriteLine( "Order ID: {0}", myOrder->orderId );
         Console::WriteLine( "Sent: {0}", myOrder->orderTime );
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle Message Queuing exceptions.
      }
      // Handle invalid serialization format.
      catch ( InvalidOperationException^ e ) 
      {
         Console::WriteLine( e->Message );
      }

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

//*************************************************
// Provides an entry point into the application.
//         
// This example sends and receives a message from
// a queue.
//*************************************************
int main()
{
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;

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

   // Receive a message from a queue.
   myNewQueue->ReceiveMessage();
   return 0;
}
using System;
using System.Messaging;

namespace MyProject
{

    // This class represents an object the following example
    // sends to a queue and receives from a queue.
    public class Order
    {
        public int orderId;
        public DateTime orderTime;
    };	

    /// <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();

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

            // Receive a message from a queue.
            myNewQueue.ReceiveMessage();

            return;
        }

        //**************************************************
        // Sends an Order to a queue.
        //**************************************************
        
        public void SendMessage()
        {
            
            // Create a new order and set values.
            Order sentOrder = new Order();
            sentOrder.orderId = 3;
            sentOrder.orderTime = DateTime.Now;

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

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

            return;
        }

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

            // Set the formatter to indicate body contains an Order.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(MyProject.Order)});
            
            try
            {
                // Receive and format the message.
                Message myMessage =	myQueue.Receive();
                Order myOrder = (Order)myMessage.Body;

                // Display message information.
                Console.WriteLine("Order ID: " +
                    myOrder.orderId.ToString());
                Console.WriteLine("Sent: " +
                    myOrder.orderTime.ToString());
            }
            
            catch (MessageQueueException)
            {
                // Handle Message Queuing exceptions.
            }

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

            return;
        }
    }
}
Imports System.Messaging

    ' This class represents an object the following example 
    ' sends to a queue and receives from a queue.
    Public Class Order
        Public orderId As Integer
        Public orderTime As DateTime
    End Class


   
    Public Class MyNewQueue


        '
        ' Provides an entry point into the application.
        '		 
        ' This example sends and receives a message from
        ' a qeue.
        '

        Public Shared Sub Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New MyNewQueue()

            ' Send a message to a queue.
            myNewQueue.SendMessage()

            ' Receive a message from a queue.
            myNewQueue.ReceiveMessage()

            Return

        End Sub


        '
        ' Sends an Order to a queue.
        '

        Public Sub SendMessage()

            ' Create a new order and set values.
            Dim sentOrder As New Order()
            sentOrder.orderId = 3
            sentOrder.orderTime = DateTime.Now

            ' Connect to a queue on the local computer.
            Dim myQueue As New MessageQueue(".\myQueue")

            ' Send the Order to the queue.
            myQueue.Send(sentOrder)

            Return

        End Sub


        '
        ' Receives a message containing an Order.
        '

        Public Sub ReceiveMessage()

            ' Connect to the a queue on the local computer.
            Dim myQueue As New MessageQueue(".\myQueue")

            ' Set the formatter to indicate the body contains an Order.
            myQueue.Formatter = New XmlMessageFormatter(New Type() _
                {GetType(Order)})

            Try

                ' Receive and format the message. 
                Dim myMessage As Message = myQueue.Receive()
                Dim myOrder As Order = CType(myMessage.Body, Order)

                ' Display message information.
                Console.WriteLine(("Order ID: " + _
                    myOrder.orderId.ToString()))
                Console.WriteLine(("Sent: " + _
                    myOrder.orderTime.ToString()))

            Catch m As MessageQueueException
                ' Handle Message Queuing exceptions.

            Catch e As InvalidOperationException
                ' Handle invalid serialization format.
                Console.WriteLine(e.Message)


                ' Catch other exceptions as necessary.

            End Try

            Return

        End Sub

End Class

備註

訊息佇列技術可讓在不同時間執行的應用程式跨異質網路和可能暫時離線的系統進行通訊。 應用程式會傳送、接收或查看 (讀取,而不需從佇列移除) 訊息。 訊息佇列是 Windows 2000 和 Windows NT 的選擇性元件,必須個別安裝。

類別 MessageQueue 是訊息佇列的包裝函式。 訊息佇列有多個版本,而且使用 MessageQueue 類別可能會根據您使用的作業系統,產生稍微不同的行為。

類別 MessageQueue 提供訊息佇列佇列的參考。 您可以在建構函式中 MessageQueue 指定路徑以連線到現有的資源,也可以在伺服器上建立新的佇列。 您必須先將 類別的新實例 MessageQueue 與現有的佇列產生關聯,才能呼叫 Send(Object)PeekReceive 。 此時,您可以操作佇列屬性,例如 CategoryLabel

MessageQueue 支援兩種類型的訊息擷取:同步和非同步。 同步方法 PeekReceive 會導致進程執行緒等候指定的時間間隔,讓新訊息抵達佇列。 非同步方法 BeginPeekBeginReceive 允許主要應用程式工作在不同的執行緒中繼續,直到訊息抵達佇列為止。 這些方法的運作方式是使用回呼物件和狀態物件線上程之間通訊資訊。

當您建立 類別的新實例 MessageQueue 時,您不會建立新的訊息佇列佇列。 相反地,您可以使用 Create(String)Delete(String)Purge 方法來管理伺服器上的佇列。

不同于 PurgeCreate(String)Delete(String)static 成員,因此您可以呼叫它們,而不需建立 類別的新實例 MessageQueue

您可以使用下列三個名稱之一來設定 MessageQueue 物件的 Path 屬性:易記名稱、 FormatNameLabel 。 佇列和屬性所 MachineName 定義的易記名稱,適用于 QueueName\MachineName 公用佇列,以及 MachineNameQueueName\\Private$ 私人佇列。 QueueName 屬性 FormatName 允許離線存取訊息佇列。 最後,您可以使用佇列的 Label 屬性來設定佇列的 Path

如需 實例 MessageQueue 的初始屬性值清單,請參閱 建 MessageQueue 構函式。

建構函式

MessageQueue()

初始化 MessageQueue 類別的新執行個體。 在無參數建構函式初始化新執行個體之後,您必須先設定執行個體的 Path 屬性,才能夠使用執行個體。

MessageQueue(String)

初始化 MessageQueue 類別的新執行個體,這個執行個體會參考指定路徑的訊息佇列。

MessageQueue(String, Boolean)

初始化 MessageQueue 類別的新執行個體,這個執行個體會參考指定路徑且具有指定讀取權限制的訊息佇列。

MessageQueue(String, Boolean, Boolean)

初始化 MessageQueue 類別的新執行個體。

MessageQueue(String, Boolean, Boolean, QueueAccessMode)

初始化 MessageQueue 類別的新執行個體。

MessageQueue(String, QueueAccessMode)

初始化 MessageQueue 類別的新執行個體。

欄位

InfiniteQueueSize

指定佇列沒有大小限制。

InfiniteTimeout

指定窺視 (Peek) 或接收訊息的方法沒有逾時限制。

屬性

AccessMode

取得值,表示佇列的存取模式。

Authenticate

取得或設定值,指出佇列是否只接受已驗證的訊息。

BasePriority

取得或設定訊息佇列用來在網路上傳送公用佇列訊息的基礎優先權 (Base Priority)。

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
CanRead

取得值,指出是否可讀取 MessageQueue

CanWrite

取得值,指出是否可寫入 MessageQueue

Category

取得或設定佇列分類。

Container

取得包含 IContainerComponent

(繼承來源 Component)
CreateTime

取得佇列在訊息佇列中建立的時間和日期。

DefaultPropertiesToSend

取得或設定應用程式傳送訊息至佇列時,會預設採用的訊息屬性值。

DenySharedReceive

取得或設定值,指出這個 MessageQueue 是否具有從訊息佇列接收訊息的獨佔存取權。

DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
EnableConnectionCache

取得或設定值,指出應用程式是否會維持連接的快取。

EncryptionRequired

取得或設定值,指出佇列是否只接受非私用 (不加密的) 訊息。

Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
FormatName

取得訊息佇列在佇列建立時產生的唯一佇列名稱。

Formatter

取得或設定對佇列寫入或讀取訊息時,用來將物件序列化成訊息主體,或者從訊息主體將物件還原序列化的格式子。

Id

取得佇列的唯一訊息佇列識別項。

Label

取得或設定佇列描述。

LastModifyTime

取得上次修改佇列屬性的時間。

MachineName

取得或設定訊息佇列位置的電腦名稱。

MaximumJournalSize

取得或設定日誌佇列的最大大小。

MaximumQueueSize

取得或設定佇列的最大值。

MessageReadPropertyFilter

取得或設定接收或窺視訊息的屬性篩選條件。

MulticastAddress

在 MSMQ 3.0 中介紹。 取得或設定與佇列相關聯的多點傳送位址。

Path

取得或設定佇列路徑。 設定 Path 會使 MessageQueue 指向新佇列。

QueueName

取得或設定識別佇列的易記名稱。

ReadHandle

取得用來從訊息佇列讀取訊息的原生控制代碼。

Site

取得或設定 ComponentISite

(繼承來源 Component)
SynchronizingObject

取得或設定封送處理從 ReceiveCompletedPeekCompleted 事件產生之事件處理常式呼叫的物件。

Transactional

取得值,指出佇列是否只接受交易。

UseJournalQueue

取得或設定值,指出是否複製接收的訊息至日誌佇列。

WriteHandle

取得用來傳送訊息至訊息佇列的原生控制代碼。

方法

BeginPeek()

啟始沒有逾時的非同步瞄核作業。作業要等到訊息可在佇列中使用之後才算完成。

BeginPeek(TimeSpan)

啟始具有指定逾時的非同步瞄核作業。作業要等到訊息可在佇列中使用,或發生逾時之後才算完成。

BeginPeek(TimeSpan, Cursor, PeekAction, Object, AsyncCallback)

啟始非同步窺視作業,該作業具有指定的逾時,並使用指定的游標、指定的窺視動作和指定的狀態物件。 狀態物件提供整個作業存留期的相關聯資訊。 這個多載會透過回呼,接收作業的事件處理常式的識別通知。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

BeginPeek(TimeSpan, Object)

啟始有指定逾時和指定狀態物件的非同步窺視作業,會在作業的整個存留期內提供相關的資訊。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

BeginPeek(TimeSpan, Object, AsyncCallback)

啟始有指定逾時和指定狀態物件的非同步窺視作業,會在作業的整個存留期內提供相關的資訊。 這個多載會透過回呼,接收作業的事件處理常式的識別通知。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

BeginReceive()

啟始沒有逾時的非同步接收作業。作業要等到訊息可以在佇列中使用之後才算完成。

BeginReceive(TimeSpan)

啟始具有指定逾時的非同步接收作業。作業要等到訊息可在佇列中使用,或發生逾時之後才算完成。

BeginReceive(TimeSpan, Cursor, Object, AsyncCallback)

初始化非同步接收作業,該作業具有指定的逾時,並使用指定的游標和指定的狀態物件。 狀態物件提供整個作業存留期的相關聯資訊。 這個多載會透過回呼,接收作業的事件處理常式的識別通知。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

BeginReceive(TimeSpan, Object)

啟始有指定逾時和指定狀態物件的非同步接收作業,會在作業的整個存留期內提供相關的資訊。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

BeginReceive(TimeSpan, Object, AsyncCallback)

啟始有指定逾時和指定狀態物件的非同步接收作業,會在作業的整個存留期內提供相關的資訊。 這個多載會透過回呼,接收作業的事件處理常式的識別通知。 在訊息可以於佇列中使用或發生逾時之後,作業才會完成。

ClearConnectionCache()

清除連接快取。

Close()

釋放 MessageQueue 配置的所有資源。

Create(String)

在指定的路徑建立非交易的訊息佇列。

Create(String, Boolean)

在指定的路徑建立交易或非交易的訊息佇列。

CreateCursor()

建立目前訊息佇列的新 Cursor

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Delete(String)

刪除 Message Queuing 伺服器上的佇列。

Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

處置 (Dispose) MessageQueue 所使用的資源 (除了記憶體之外)。

EndPeek(IAsyncResult)

完成指定的非同步窺視作業。

EndReceive(IAsyncResult)

完成指定的非同步接收作業。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Exists(String)

判斷指定路徑上是否存在訊息佇列。

GetAllMessages()

傳回佇列中的所有訊息。

GetEnumerator()
已淘汰.

列舉佇列中的訊息。 GetEnumerator() 已被取代。 應改用 GetMessageEnumerator2()

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetMachineId(String)

取得這個 MessageQueue 參考之佇列所在位置的電腦識別項。

GetMessageEnumerator()
已淘汰.

為佇列中的所有訊息建立列舉值物件。 GetMessageEnumerator() 已被取代。 應改用 GetMessageEnumerator2()

GetMessageEnumerator2()

為佇列中的所有訊息建立列舉值物件。

GetMessageQueueEnumerator()

提供順向資料指標語意,以列舉網路上的所有公用佇列。

GetMessageQueueEnumerator(MessageQueueCriteria)

提供順向資料指標語意,以列舉網路上所有符合指定準則的公用佇列。

GetPrivateQueuesByMachine(String)

擷取所指定電腦上的所有私用佇列。

GetPublicQueues()

擷取網路上所有的公用佇列。

GetPublicQueues(MessageQueueCriteria)

擷取網路上符合指定準則的所有公用佇列。

GetPublicQueuesByCategory(Guid)

擷取網路上屬於指定分類的所有公用佇列。

GetPublicQueuesByLabel(String)

擷取網路上具有指定標籤的所有公用佇列。

GetPublicQueuesByMachine(String)

擷取位於指定電腦上的所有公用佇列。

GetSecurityContext()

擷取 MSMQ 在這次呼叫時與目前使用者 (執行緒識別) 產生關聯的安全性內容。

GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
Peek()

傳回而不移除 (窺視) 這個 MessageQueue 所參考佇列中的第一個訊息。 Peek() 方法是同步的,因此會封鎖目前的執行緒,直到訊息可以使用為止。

Peek(TimeSpan)

傳回而不移除 (窺視) 這個 MessageQueue 所參考佇列中的第一個訊息。 Peek() 方法是同步的,因此會封鎖目前的執行緒,直到訊息可以使用或發生指定的逾時為止。

Peek(TimeSpan, Cursor, PeekAction)

使用指定的游標傳回而不移除 (窺視) 佇列中的目前或下一則訊息。 Peek() 方法是同步的,因此會封鎖目前的執行緒,直到訊息可以使用或發生指定的逾時為止。

PeekByCorrelationId(String)

窺視符合指定關聯識別項的訊息,而且在佇列中目前沒有指定關聯識別項的訊息時,立即引發例外狀況。

PeekByCorrelationId(String, TimeSpan)

窺視符合指定的關聯識別項的訊息,並且等候佇列中出現具有指定關聯識別項的訊息,或者等候直到逾時到期。

PeekById(String)

窺視訊息識別項符合 id 參數的訊息。

PeekById(String, TimeSpan)

窺視訊息識別項符合 id 參數的訊息。 等待直到訊息出現在佇列中,或等到發生逾時。

PeekByLookupId(Int64)

在 MSMQ 3.0 中介紹。 窺視符合非交易佇列之指定查詢識別項的訊息。

PeekByLookupId(MessageLookupAction, Int64)

在 MSMQ 3.0 中介紹。 窺視佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

Purge()

刪除佇列中所包含的所有訊息。

Receive()

接收由 MessageQueue 參考的第一個在佇列中可用的訊息。 這個呼叫是同步的,而且會阻礙目前執行的執行緒,直到訊息可以使用。

Receive(MessageQueueTransaction)

接收由 MessageQueue 參考的第一個在交易佇列中可用的訊息。 這個呼叫是同步的,而且會阻礙目前執行的執行緒,直到訊息可以使用。

Receive(MessageQueueTransactionType)

接收由 MessageQueue 參考的第一個在佇列中可用的訊息。 這個呼叫是同步的,而且會阻礙目前執行的執行緒,直到訊息可以使用。

Receive(TimeSpan)

接收 MessageQueue 所參考之佇列中的第一個可用訊息,並等候直到佇列中有可用訊息,或者逾時到期。

Receive(TimeSpan, Cursor)

使用指定的游標接收佇列中的目前訊息。 如果沒有可用的訊息,則這個方法會等到有訊息可用或逾時為止。

Receive(TimeSpan, Cursor, MessageQueueTransaction)

使用指定的游標接收佇列中的目前訊息。 如果沒有可用的訊息,則這個方法會等到有訊息可用或逾時為止。

Receive(TimeSpan, Cursor, MessageQueueTransactionType)

使用指定的游標接收佇列中的目前訊息。 如果沒有可用的訊息,則這個方法會等到有訊息可用或逾時為止。

Receive(TimeSpan, MessageQueueTransaction)

接收 MessageQueue 所參考之交易佇列中的第一個可用訊息,並且等候直到佇列中出現可用訊息,或逾時過期為止。

Receive(TimeSpan, MessageQueueTransactionType)

接收由 MessageQueue 參考的第一個在佇列中可用的訊息。 這個呼叫是同步的,並且會等候直到佇列中出現可用訊息,或逾時過期為止。

ReceiveByCorrelationId(String)

接收符合指定關聯識別項的訊息 (從非交易佇列中),如果佇列中目前不存在具有指定關聯識別項的訊息,則立即引發例外狀況。

ReceiveByCorrelationId(String, MessageQueueTransaction)

接收符合指定關聯識別項的訊息 (從交易佇列中),如果佇列中目前不存在具有指定關聯識別項的訊息,則立即引發例外狀況。

ReceiveByCorrelationId(String, MessageQueueTransactionType)

接收符合指定關聯識別項的訊息,如果佇列中目前不存在具有指定關聯識別項的訊息,則立即引發例外狀況。

ReceiveByCorrelationId(String, TimeSpan)

接收符合指定關聯識別項的訊息 (從非交易佇列中),並且等待佇列中出現具有指定關聯識別項的訊息,或者逾時到期。

ReceiveByCorrelationId(String, TimeSpan, MessageQueueTransaction)

接收符合指定關聯識別項的訊息 (從交易佇列中),並且等待佇列中出現具有指定關聯識別項的訊息,或者逾時到期。

ReceiveByCorrelationId(String, TimeSpan, MessageQueueTransactionType)

接收符合指定關聯識別項的訊息,並且等待佇列中出現具有指定關聯識別項的訊息,或者逾時到期。

ReceiveById(String)

從非交易佇列中接收符合指定識別項的訊息,如果佇列中目前不存在具有指定識別項的訊息,則立即引發例外狀況。

ReceiveById(String, MessageQueueTransaction)

接收符合指定識別項的訊息 (從交易佇列中),如果佇列中目前不存在具有指定識別項的訊息,則立即引發例外狀況。

ReceiveById(String, MessageQueueTransactionType)

接收符合指定識別項的訊息,如果佇列中目前不存在具有指定識別項的訊息,則立即引發例外狀況。

ReceiveById(String, TimeSpan)

接收符合指定識別項的訊息 (從非交易佇列中),並且等待佇列中出現具有指定識別項的訊息,或者逾時到期。

ReceiveById(String, TimeSpan, MessageQueueTransaction)

接收符合指定識別項的訊息 (從交易佇列中),並且等待佇列中出現具有指定識別項的訊息,或者逾時到期。

ReceiveById(String, TimeSpan, MessageQueueTransactionType)

接收符合指定識別項的訊息,並且等待佇列中出現具有指定識別項的訊息,或者逾時到期。

ReceiveByLookupId(Int64)

在 MSMQ 3.0 中介紹。 接收符合非交易佇列之指定查詢識別項的訊息。

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransaction)

在 MSMQ 3.0 中介紹。 接收交易佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

ReceiveByLookupId(MessageLookupAction, Int64, MessageQueueTransactionType)

在 MSMQ 3.0 中介紹。 使用指定的交易內容接收佇列中的特定訊息。 訊息可以由查閱識別項指定,或由訊息在佇列前面或結尾的位置來指定。

Refresh()

重新整理由 MessageQueue 所表示的屬性,以反映資源的目前狀態。

ResetPermissions()

將使用權限清單重設為作業系統的預設值。 移除任何附加至預設清單的佇列使用權限。

Send(Object)

將物件傳送至這個 MessageQueue 參考的非交易佇列。

Send(Object, MessageQueueTransaction)

將物件傳送至這個 MessageQueue 參考的交易佇列。

Send(Object, MessageQueueTransactionType)

將物件傳送至這個 MessageQueue 參考的佇列。

Send(Object, String)

將物件傳送至這個 MessageQueue 參考的非交易佇列,並指定訊息的標籤。

Send(Object, String, MessageQueueTransaction)

將物件傳送至這個 MessageQueue 參考的交易佇列,並指定訊息的標籤。

Send(Object, String, MessageQueueTransactionType)

將物件傳送至這個 MessageQueue 參考的佇列,並指定訊息的標籤。

SetPermissions(AccessControlList)

根據存取控制清單的內容指派佇列的存取權限。

SetPermissions(MessageQueueAccessControlEntry)

根據存取控制項目的內容指派佇列的存取權限。

SetPermissions(String, MessageQueueAccessRights)

為電腦、群組或使用者提供指定的存取權限。

SetPermissions(String, MessageQueueAccessRights, AccessControlEntryType)

以指定的存取控制類型 (允許、拒絕、撤銷或設定),為電腦、群組或使用者提供指定的存取權限。

ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)
PeekCompleted

發生於訊息已讀取但未從佇列中移除時。 這是非同步作業 BeginPeek() 的結果。

ReceiveCompleted

發生於從佇列移除訊息時。 這個事件是由非同步作業 BeginReceive() 所引發。

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

執行緒安全性

GetAllMessages()只有 方法是安全線程。

另請參閱