This chapter tells about binary format protocols AMF and Hessian supported by Exadel Flamingo and known issues with using Hessian 2.
Pay your attention to a summary table below to see the communication protocols supported for the client and the server parts of the application used by Exadel Flamingo.
Table 7.1.
| Client Technology | Supported Communication Protocols | |
|---|---|---|
| Seam | Spring | |
| Flex | AMF, Hessian | AMF, Hessian |
| JavaFX | Hessian | Hessian |
Hessian is a binary web service protocol that makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. It is well-suited to sending binary data without any need to extend the protocol with attachments.
Hessian is a binary cross-platform remoting protocol. Most cross-platform protocols are XML-based, and thus sacrifice a significant amount of performance in order to achieve interoperability. Hessian’s draw is that it achieves cross-platform interoperability with minimal performance degradation.
The benefits of Hessian 2 protocol usage:
It does not require an external schema or interface definitions
It is language-independent, including supporting scripting languages
It is simple, compact and fast
It supports encryption, compression, signature, and transaction context envelopes
Hessian shows excellent response time. Comparison of Hessian 2 with other protocols can be found at http://daniel.gredler.net/2008/01/07/java-remoting-protocol-benchmarks/.
We conducted some tests to compare performance of Hessian and AMF and they showed that Hessian 2 has, on average, approximately one and a half better performance results with little amounts of data (a full cycle was taken into consideration: serialization, transfer, deserialization).
Listed below is a list of known issues for Hessian 2:
"Date" issue. Be aware that Hessian may deserialize objects of the java.sql.Date class incorrectly, that means you will get a result on client different from what was sent from the server.
"mx.collections.ArrayCollection" issue. Hessian has no serializer for the mx.collections.ArrayCollection class, thus, while sending objects of this class to the server via the Hessian protocol they are serialized and deserialized into HashMap. Workaround for this may be the usage of the Array class instead.
Deserialization to ActionScript Classes issue. Specify the returnType property for HessianOperation while requesting typified compound objects from the server using the Hessian protocol; otherwise they will be deserialized into dynamic objects of the Object type.
"Fault" event issue. Request of the HessianOperation.send method generates a fault event in any result of operation (successful/unsuccessful); that limits usage of fault event listeners.
Uninitialized Number deserialization issue. When sending a Number object from client to the server and the value of the object is not initialized (NaN), Hessian deserializes such an object into the Double object and initializes it to 0.
Action Message Format (AMF) is a compact binary format that is used to serialize ActionScript object graphs. Once serialized an AMF encoded object graph may be used to persist and retrieve the public state of an application across sessions or allow two endpoints to communicate through the exchange of strongly typed data.
The benefits of AMF protocol usage:
File size - AMF objects are of a very small volume due to the fact that they are compressed using “zlib”
Quick serializing/unserializing - speed encoding/decoding in the AMF is very high, even with little memory and a slow processor
Support for standard data types as well as their own classes - you can serialize virtually any object
As no specification was published for the AMF protocol by Adobe® during the development of Exadel Flamingo and no standalone implementation exists, Exadel Flamingo uses its own library: AMF-serializer which is licensed under the GNU LGPL. This library with source code is shipped with the Exadel Flamingo download bundle. For more information see "http://code.google.com/p/amf-serializer/".