Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 4 Sending and Receiving Data : How Adapters Send Application Data

How Adapters Send Application Data
This section discusses sending data using the SDK send() method. For simplicity, the discussion uses a publisher as an example. The same concepts apply if data is sent as part of a client/server interaction.
Sending MInstance Data
An SDK MPublisher has various send() methods that take an MInstance (or other composite MData subclass) as an argument. Because the publisher has been created to use one of the supported message formats, you can pass in the MInstance and the publisher handles the serialization appropriately.
Sending MTree Data
Custom adapters can also send an MTree. In that case, the custom adapter must explicitly serialize the MInstance.
It is recommended that you use the MPublisher.send() method to send an MInstance and let the SDK perform serialization.
If you explicitly serialize the MInstance, the serialization method must know which message format to use. Choose one of the following options:
Set a global variable (MESSAGEFORMAT) to determine the message format. This variable is then used by the SDK each time the MTree is serialized. Set the global variable as follows:MAppProperties.set(MESSAGEFORMAT, ...)
   MInstance foo( ... );
   // set the data into the foo instance
   //...
   MTree x;
   foo.serialize( x, Pub.getMessageFormat() );
   Pub.send( x );
If an MTree is produced with a message format that does not match the sending endpoint, the endpoint is forced to convert the MTree to the matching message format. The performance cost of doing so is often unacceptable for production systems.
After you have serialized the MInstance, call the send() method.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved