IMessageFormatter 接口


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

public interface class IMessageFormatter : ICloneable
public interface IMessageFormatter : ICloneable
type IMessageFormatter = interface
    interface ICloneable
Public Interface IMessageFormatter
Implements ICloneable


当应用程序使用MessageQueue类的实例将消息发送到队列时, 格式化程序将对象 (可以是任何类的实例) 序列化为流, 并将其插入消息正文。When an application sends a message to the queue using an instance of the MessageQueue class, the formatter serializes the object (which can be an instance of any class) into a stream and inserts it into the message body. 当使用MessageQueue从队列进行读取时, 格式化程序将消息数据Body反序列化为的属性MessageWhen reading from a queue using a MessageQueue, the formatter deserializes the message data into the Body property of a Message.

BinaryMessageFormatterActiveXMessageFormatter相比, 提供更快XmlMessageFormatter的吞吐量。BinaryMessageFormatter and ActiveXMessageFormatter provide faster throughput than the XmlMessageFormatter. ActiveXMessageFormatter允许与 Visual Basic 6.0 消息队列应用程序的互操作性。The ActiveXMessageFormatter allows interoperability with Visual Basic 6.0 Message Queuing applications. XmlMessageFormatter是松散耦合的, 这意味着服务器和客户端可以对单独发送和接收的类型进行版本保证。The XmlMessageFormatter is loosely coupled, which means that the server and client can version the type that is sent and received independently.



在类中实现时,确定格式化程序是否可以反序列化消息的内容。When implemented in a class, determines whether the formatter can deserialize the contents of the message.


创建作为当前实例副本的新对象。Creates a new object that is a copy of the current instance.

(继承自 ICloneable)

在类中实现时,读取给定消息中的内容并创建包含该消息中的数据的对象。When implemented in a class, reads the contents from the given message and creates an object that contains data from the message.

Write(Message, Object)

在类中实现时,将对象序列化到消息体中。When implemented in a class, serializes an object into the body of the message.