命名空间messages_System.Messaging

越骏俊
2023-12-01

System.Messaging 命名空间

提供具有以下功能的类:连接、监视和管理网络上的消息队列,以及发送、接收或查看消息。

Provides classes that allow you to connect to, monitor, and administer message queues on the network and send, receive, or peek messages.

本文内容

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

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

使用与 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.

使用二进制格式,将一个对象(或连接的对象的整个图形)序列化成“消息队列”消息体或从“消息队列”消息体反序列化一个对象。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 用于在读取队列的消息时保持 MessageQueue 中的特定位置。A Cursor is used to maintain a specific location in a MessageQueue when reading the queue's messages.

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

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

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

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

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

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

Filters message queues when performing a query using the MessageQueue class's GetPublicQueues() method.

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

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

允许安装并配置应用程序运行所需的队列。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.

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

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

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

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

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.

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.

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

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

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

接口

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

枚举

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

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

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

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

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

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

使用 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.

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

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

指定消息队列在消息传递到队列的过程中应用于该消息的优先级,以及指定何时将消息插入目标队列。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.

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

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

Defines access levels used by System.Messaging permission classes.

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

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

标识消息的类型。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.

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

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

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

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

委托

注解

类的成员 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.

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.

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:

GetPrivateQueuesByMachine(String) enables the retrieval of the private queues on a computer.

类的其他方法 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.

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.

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.

 类似资料: