Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An AMQFrame is the basic unit transmitted over the network, and contains a body which is the real payload. There are numerous method frames, which are subclasses of AMQMethodBody. The method body subclasses are all code generated using XSLT from the protocol specification. The ContentHeaderBody can support different types of content properties or metadata (examples being file or stream in addition to basic which is standard JMS-style messaging).

...

The classes involved in decoding are illustrated in this UML class diagram:

Image RemovedImage Added

The AMQDataBlockDecoder has only two methods: decodable() in which it attempts to read enough information from the supplied buffer to determine whether it has all the data and whether it appears to represent a known data block. If it needs more data, it return false. If the frame appears to be invalid it throws an exception.

The decoder stores the factories for the known HeartbeatBody, ContentHeaderBody and ContentBody frame types in a hash table, keyed an array, indexed on type. Assuming the decodable() method return true, the The AMQMethodBody factory is version specific and retrieved from the current session. The decoder constructs an AMQFrame, looks up passing in the body factory based on the body type read from the buffer and calls populateFromBuffer on the frame, passing in the the appropriate factory. The result of that call is either a fully populated frame or an exception being thrown if data is invalid or inconsistent.

The MethodBodyDecoderRegistry is generated from the ASL version of the protocol specification. (ASL is simply an XML format for describing the protocol). Each method is registered by protocol class and protocol method and when looked up by the AMQMethodBodyFactory an instance of the appropriate method body is returned. The generated code for the methods handles the reading and writing of the bytes to and from ByteBuffers as well as calculation of the size of the populated method bodies.