MessageQueue 类

定义

提供对“消息队列”服务器上的队列的访问。

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 指定路径以连接到现有资源,也可以在服务器上创建新队列。 在调用 Send(Object)PeekReceive之前,必须将 类的新实例 MessageQueue 与现有队列相关联。 此时,可以操作队列属性,例如 CategoryLabel

MessageQueue 支持两种类型的消息检索:同步和异步。 同步方法和 PeekReceive会导致进程线程等待指定的时间间隔,以便新消息到达队列。 异步方法和 BeginPeekBeginReceive允许main应用程序任务在单独的线程中继续,直到消息到达队列。 这些方法的工作原理是使用回调对象和状态对象在线程之间传达信息。

创建 类的新实例 MessageQueue 时,不会创建新的消息队列队列。 相反,可以使用 Create(String)Delete(String)Purge 方法来管理服务器上的队列。

Purge不同, Create(String)Delete(String)static 成员,因此无需创建新类实例 MessageQueue 即可调用它们。

可以使用三个名称之一设置 MessageQueue 对象的 Path 属性:友好名称 、 FormatNameLabel。 友好名称(由队列的 MachineName 和 属性定义)MachineName\QueueName用于公共队列和\QueueNameMachineNamePrivate$\专用队列。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

指定对查看或接收消息的方法不存在超时设定。

属性

AccessMode

获取一个值,该值指示队列的访问模式。

Authenticate

获取或设置一个值,该值指示队列是否仅接受经过身份验证的消息。

BasePriority

获取或设置基优先级,“消息队列”使用该基优先级在网络上传送公共队列的消息。

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)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。

(继承自 MarshalByRefObject)
Delete(String)

删除“消息队列”服务器上的队列。

Dispose()

释放由 Component 使用的所有资源。

(继承自 Component)
Dispose(Boolean)

处置由 MessageQueue 占用的资源(内存除外)。

EndPeek(IAsyncResult)

完成指定的异步查看操作。

EndReceive(IAsyncResult)

完成指定的异步接收操作。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
Exists(String)

确定指定的路径中是否存在“消息队列”队列。

GetAllMessages()

返回位于队列中的所有消息。

GetEnumerator()
已过时.

枚举队列中的消息。 GetEnumerator() 已弃用。 应改用 GetMessageEnumerator2()

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetLifetimeService()
已过时.

检索控制此实例的生存期策略的当前生存期服务对象。

(继承自 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()只有 方法是线程安全的。

另请参阅