System.Messaging Namespace

System.Messaging 命名空间提供一些类,您可以使用这些类连接到、监视和管理网络上的消息队列,并发送、接收或查看消息。 The System.Messaging namespace provides classes that allow you to connect to, monitor, and administer message queues on the network and send, receive, or peek messages.

AccessControlEntry

为受信者(用户、组或计算机)指定访问权限,以执行常规任务的应用程序特定的实现。Specifies access rights for a trustee (user, group, or computer) to perform application-specific implementations of common tasks.

AccessControlList

包含一个访问控制项列表,这些项为一个或多个受信者指定访问权限。Contains a list of access control entries, specifying access rights for one or more trustees.

ActiveXMessageFormatter

使用与 MSMQ ActiveX 组件兼容的格式,将基元数据类型和其他对象序列化成“消息队列”消息体或从“消息队列”消息体反序列化基元数据类型和其他对象。Serializes or deserializes primitive data types and other objects to or from the body of a Message Queuing message, using a format that is compatible with the MSMQ ActiveX Component.

BinaryMessageFormatter

使用二进制格式,将一个对象(或连接的对象的整个图形)序列化成“消息队列”消息体或从“消息队列”消息体反序列化一个对象。Serializes or deserializes an object, or an entire graph of connected objects, to or from the body of a Message Queuing message, using a binary format.

Cursor

Cursor 用于在读取队列的消息时保持 MessageQueue 中的特定位置。A Cursor is used to maintain a specific location in a MessageQueue when reading the queue's messages.

DefaultPropertiesToSend

指定在向消息队列发送 Message 实例以外的对象时所使用的默认属性值。Specifies the default property values that will be used when sending objects other than Message instances to a message queue.

Message

提供对定义消息队列消息所需的属性的访问。Provides access to the properties needed to define a Message Queuing message.

MessageEnumerator

提供一个只进游标,以枚举通过消息队列中的消息。Provides a forward-only cursor to enumerate through messages in a message queue.

MessagePropertyFilter

控制并选择从消息队列查看或接收消息时检索的属性。Controls and selects the properties that are retrieved when peeking or receiving messages from a message queue.

MessageQueue

提供对“消息队列”服务器上的队列的访问。Provides access to a queue on a Message Queuing server.

MessageQueueAccessControlEntry

为受信者(用户、组或计算机)指定执行消息队列任务的访问权限。Specifies access rights for a trustee (user, group, or computer) to perform Message Queuing tasks.

MessageQueueCriteria

当执行查询时使用 MessageQueue 类的 GetPublicQueues() 方法筛选消息队列。Filters message queues when performing a query using the MessageQueue class's GetPublicQueues() method.

MessageQueueEnumerator

提供一个只进游标,以枚举通过消息队列中的消息。Provides a forward-only cursor to enumerate through messages in a message queue.

MessageQueueException

发生 Microsoft 消息队列内部错误时引发的异常。The exception that is thrown if a Microsoft Message Queuing internal error occurs.

MessageQueueInstaller

允许安装并配置应用程序运行所需的队列。Allows you to install and configure a queue that your application needs in order to run. 安装实用工具(例如 InstallUtil.exe)在安装 MessageQueue 时调用此类。This class is called by the installation utility, for example, InstallUtil.exe, when installing a MessageQueue.

MessageQueuePermission

允许用于消息的代码访问权限的控制。Allows control of code access permissions for messaging.

MessageQueuePermissionAttribute

允许进行声明 MessageQueue 权限检查。Allows declarative MessageQueue permission checks.

MessageQueuePermissionEntry

为消息定义代码访问安全权限集的最小单位。Defines the smallest unit of a code access security permission set for messaging.

MessageQueuePermissionEntryCollection

包含 MessageQueuePermissionEntry 对象的强类型集合。Contains a strongly typed collection of MessageQueuePermissionEntry objects.

MessageQueueTransaction

提供消息队列内部事务。Provides a Message Queuing internal transaction.

MessagingDescriptionAttribute

指定属性或事件的说明。Specifies a description for a property or event.

PeekCompletedEventArgs

PeekCompleted 事件提供数据。Provides data for the PeekCompleted event. 当异步查看操作调用事件处理程序时,此类的一个实例将被传递给该处理程序。When your asynchronous peek operation calls an event handler, an instance of this class is passed to the handler.

ReceiveCompletedEventArgs

ReceiveCompleted 事件提供数据。Provides data for the ReceiveCompleted event. 当异步接收操作调用事件处理程序时,此类的一个实例将被传递给该处理程序。When your asynchronous receive operation calls an event handler, an instance of this class is passed to the handler.

SecurityContext

表示队列消息的安全上下文。Represents the security context for a message in a queue.

Trustee

指定要向其应用访问控制项的用户帐户、组帐户或登录会话。Specifies a user account, group account, or logon session to which an access control entry applies.

XmlMessageFormatter

使用基于 XSD 架构定义的 XML 格式,将对象序列化和反序列化为消息体或从消息体序列化和反序列化对象。Serializes and deserializes objects to or from the body of a message, using the XML format based on the XSD schema definition.

接口

IMessageFormatter

从“消息队列”消息体序列化或反序列化对象。Serializes or deserializes objects from the body of a Message Queuing message.

枚举

AccessControlEntryType

指定是允许、拒绝还是撤消受信者的访问权限。Specifies whether to allow, deny, or revoke access rights for a trustee.

AcknowledgeTypes

指定消息队列返回到发送应用程序的确认消息类型。Specifies the types of acknowledgment message that Message Queuing returns to the sending application.

Acknowledgment

指定尝试的消息传递的结果。Specifies the result of an attempted message delivery.

CryptographicProviderType

指定可用于验证数字签名的加密服务提供程序。Specifies the cryptographic service providers available for validating digital signatures.

EncryptionAlgorithm

指定用于对私有消息的消息体进行加密的加密算法。Specifies the encryption algorithm used to encrypt the message body of a private message.

EncryptionRequired

指定队列接收的消息的隐私等级。Specifies the privacy level of messages received by the queue.

GenericAccessRights

使用 Windows 2000 和 Windows NT 访问格式指定一组公共访问权限,消息队列将这些权限映射为标准的和对象特定的读取、写入和执行访问权限。Uses the Windows 2000 and Windows NT access format to specify a set of common access rights that Message Queuing maps to both standard and object-specific access rights for reading, writing, and executing.

HashAlgorithm

指定对消息进行身份验证时消息队列所用的哈希算法。Specifies the hash algorithm used by Message Queuing when authenticating messages.

MessageLookupAction

指定要从消息队列中查看或接收的消息。Specifies a message to peek at or receive from a message queue.

MessagePriority

指定消息队列在消息传递到队列的过程中应用于该消息的优先级,以及指定何时将消息插入目标队列。Specifies the priority Message Queuing applies to a message while it is en route to a queue, and when inserting the message into the destination queue.

MessageQueueAccessRights

为特定于消息队列的操作指定一组对象特定的访问权限。Specifies a set of object-specific access rights for operations specific to Message Queuing.

MessageQueueErrorCode

标识在消息队列应用程序中发生的并生成 MessageQueueException 异常的错误源。Identifies the source of an error that occurred within the Message Queuing application and generated a MessageQueueException exception.

MessageQueuePermissionAccess

定义 System.Messaging 权限类使用的访问级别。Defines access levels used by System.Messaging permission classes.

MessageQueueTransactionStatus

指定内部消息队列事务的状态。Specifies the state of an internal Message Queuing transaction.

MessageQueueTransactionType

指定消息队列事务的类型。Specifies the type of a Message Queuing transaction.

MessageType

标识消息的类型。Identifies the type of a message. 消息可以是典型消息队列消息、肯定(到达和读取)或否定(到达和读取)确认消息或报告消息。A message can be a typical Message Queuing message, a positive (arrival and read) or negative (arrival and read) acknowledgment message, or a report message.

PeekAction

指示是查看队列中的当前消息还是下一条消息。Indicates whether to peek the current message in a queue, or the next message.

QueueAccessMode

在创建时为 MessageQueue 指定访问模式。Specifies the access mode for a MessageQueue at creation time.

StandardAccessRights

指定一组标准访问权限,这些权限与大多数安全对象类型所共有的操作相对应。Specifies a set of standard access rights that correspond to operations common to most types of securable objects.

TrusteeType

指定受信者的类型。Specifies the type of a trustee.

委托

PeekCompletedEventHandler

表示将用来处理 PeekCompletedMessageQueue 事件的方法。Represents the method that will handle the PeekCompleted event of a MessageQueue.

ReceiveCompletedEventHandler

表示将用来处理 ReceiveCompletedMessageQueue 事件的方法。Represents the method that will handle the ReceiveCompleted event of a MessageQueue.

注解

成员MessageQueue类包含用于读取和向队列写入消息的以下方法:Members of the MessageQueue class include the following methods for reading and writing messages to the queue:

  • Send方法使你的应用程序将消息写入队列。The Send method enables your application to write messages to the queue. 该方法的重载使您能够指定是否要发送邮件使用Message(其中提供了详细的控制您发送的信息) 或任何其他托管的对象,包括特定于应用程序的类。Overloads of the method enable you to specify whether to send your message using a Message (which provides detailed control over the information you send) or any other managed object, including application-specific classes. 作为事务的一部分,该方法还支持发送消息。The method also supports sending messages as part of a transaction.

  • ReceiveReceiveById,和ReceiveByCorrelationId方法提供了用于从队列读取消息的功能。The Receive, ReceiveById, and ReceiveByCorrelationId methods provide functionality for reading messages from a queue. Send方法,这些方法提供重载,支持事务性队列处理。Like the Send method, these methods provide overloads that support transactional queue processing. 这些方法还提供具有超时的重载。These methods also provide overloads with time-out.

    Out 参数,使处理继续进行队列为空。Out parameters that enable processing to continue if the queue is empty. 因为这些方法是同步处理的示例,它们会中断当前线程,直到可用消息,则除非您指定的超时值。Because these methods are examples of synchronous processing, they interrupt the current thread until a message is available, unless you specify a time-out.

  • Peek方法是类似于Receive,但它不会导致一条消息,它读取时从队列中删除。The Peek method is similar to Receive, but it does not cause a message to be removed from the queue when it is read. 因为Peek不会更改队列内容没有重载以支持事务处理。Because Peek does not change the queue contents, there are no overloads to support transactional processing. 但是,由于Peek,例如Receive、 以同步方式从队列中读取消息、 重载的方法支持以防止线程无限期地等待指定超时。However, because Peek, like Receive, reads messages synchronously from the queue, overloads of the method do support specifying a time-out in order to prevent the thread from waiting indefinitely.

  • BeginPeekEndPeek(IAsyncResult)BeginReceive,和EndReceive(IAsyncResult)方法提供方法以异步方式从队列中读取消息。The BeginPeek, EndPeek(IAsyncResult), BeginReceive, and EndReceive(IAsyncResult) methods provide ways to asynchronously read messages from the queue. 它们不会等待消息到达队列中时中断当前线程。They do not interrupt the current thread while waiting for a message to arrive in the queue.

以下方法MessageQueue类提供用于按指定的条件检索队列的列表和确定是否存在特定队列的功能:The following methods of the MessageQueue class provide functionality for retrieving lists of queues by specified criteria and determining if specific queues exist:

其他方法MessageQueue类提供了以下功能:Other methods of the MessageQueue class provide the following functionality:

  • 创建和删除消息队列队列。Creating and deleting Message Queueing queues.

  • 使用消息枚举器来单步执行队列中的消息。Using a message enumerator to step through the messages in a queue.

  • 用于循环访问系统上的队列使用一个队列的枚举器。Using a queue enumerator for iterating through the queues on the system.

  • 设置基于 ACL 的访问权限。Setting ACL-based access rights.

  • 使用连接缓存。Working with the connection cache.

Message类提供细致的控制发送到队列的信息,该对象用于从队列接收或查看消息时。The Message class provides detailed control over the information you send to a queue, and is the object used when receiving or peeking messages from a queue. 消息正文的属性除了Message类包括确认设置、 格式化程序选择、 标识、 身份验证和加密的信息、 时间戳、 有关使用跟踪、 服务器日志记录,指示和死信队列和事务数据。Besides the message body, the properties of the Message class include acknowledgment settings, formatter selection, identification, authentication and encryption information, timestamps, indications about using tracing, server journaling, and dead-letter queues, and transaction data.

MessageQueue组件是有以下三个格式化程序,使您能够序列化和反序列化消息从队列发送和接收相关联:The MessageQueue component is associated with the following three formatters, which enable you to serialize and deserialize messages sent and received from queues:

  • XmlMessageFormatter提供松散耦合的消息传递,启用客户端和服务器上的序列化类型的独立版本控制。The XmlMessageFormatter provides loosely coupled messaging, enabling independent versioning of serialized types on the client and server.

  • ActiveXMessageFormatter与 MSMQ COM 控件兼容。The ActiveXMessageFormatter is compatible with the MSMQ COM control. 它允许您将可以接收的控件的类型发送并接收由控件发送的类型。It allows you to send types that can be received by the control and to receive types that were sent by the control.

  • BinaryMessageFormatter提供更快的替代方法来XmlMessageFormatter,但不支持的松散耦合的消息传送的权益。The BinaryMessageFormatter provides a faster alternative to the XmlMessageFormatter, but without the benefit of loosely coupled messaging.

中的其他类Messaging命名空间支持代码访问和基于 ACL 的安全筛选Message时从队列中读取消息并使用事务时发送和接收消息的属性。Other classes in the Messaging namespace support code-access and ACL-based security, filtering Message properties when reading messages from a queue, and using transactions when sending and receiving messages.