Sending a Persistent Object (COM)
A version of this page is also available for
4/8/2010
Message Queuing supports sending and receiving serialized objects that support IPersistStream and IPersistStorage. Many persistent objects, such as all Microsoft Office documents, can be sent as the body of an Message Queuing message.
When sending an object as the body of a message, Message Queuing seamlessly invokes the object's IPersist interface. In this way, when the message is sent, the persistent state of the object is serialized into the message body using the object's supplied IPersist interface.
At the receiving end, an implementation of the object's interface must be installed to use the object when it is removed from the queue.
The following example sends a Microsoft® Word 8.0 document to a destination queue. This code could be modified to send any persistent object.
To send a Microsoft Word 8.0 document
Make sure that Microsoft Word 8.0 is installed on your computer.
Add a reference to Microsoft Word 8.0. Create a destination queue and open it with send access.
Create the Microsoft Word document object.
Create and send a message. Set the body of the message to the document object.
Open the queue with receive access and retrieve the message.
Create a new object using the body of the retrieved message.
See Also
Concepts
MSMQ COM Support
Using the COM Components
MSMQ Security