qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Qpid > Qpid Design - Framing
Date Thu, 03 Sep 2009 15:52:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/qpid/Qpid+Design+-+Framing">Qpid
Design - Framing</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~aidan">Aidan
Skinner</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h3><a name="QpidDesign-Framing-FrameClasses"></a>Frame Classes</h3>

<p>The framing definition in the protocol specification maps quite nicely to an object-oriented
representation. The class diagram is shown below:</p>

<p><img src="/confluence/download/attachments/28376/FramingClassDiagram.gif" align="absmiddle"
border="0" /></p>

<p>The <tt>AMQDataBlock</tt> at the root of the hierarchy defines a <tt>writePayload</tt>
method that subclasses implement in order to be able to transform themselves into bytes. This
is called by the encoder, documented below. The decoding (from bytes into objects) is slightly
more complex since it involves factories for the instantiation of the correct objects (again
documented below).</p>

<p>An <tt>AMQFrame</tt> 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 <tt>AMQMethodBody</tt>. The method body subclasses are all code
generated from the protocol specification. The ContentHeaderBody can support different types
of content properties or metadata (examples being file or stream in addition to <em>basic</em>
which is standard JMS-style messaging).</p>

<p><tt>ContentBody</tt> is a lightweight wrapper for message data.</p>

<h3><a name="QpidDesign-Framing-Encoding"></a>Encoding</h3>

<p>Encoding is a straightforward process. The <tt>AMQDataBlock</tt> class
has only two method: <tt>getSize()</tt> and <tt>writePayloadToBuffer(ByteBuffer)</tt>.
The encoder simply needs to ask the data block its size, allocate a buffer of that size, then
ask the data block to write itself into the buffer.</p>

<h3><a name="QpidDesign-Framing-Decoding"></a>Decoding</h3>

<p>The classes involved in decoding are illustrated in this UML class diagram:</p>

<p><img src="/confluence/download/attachments/28376/frame-decoding.png" align="absmiddle"
border="0" /></p>

<p>The <tt>AMQDataBlockDecoder</tt> has only two methods: <tt>decodable()</tt>
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.</p>

<p>The decoder stores the factories for HeartbeatBody, ContentHeaderBody and ContentBody
frame types in an array, indexed on type. The AMQMethodBody factory is version specific and
retrieved from the current session. The decoder constructs an <tt>AMQFrame</tt>,
passing in the factory 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.</p>

<p>The <tt>MethodBodyDecoderRegistry</tt> is generated from the protocol
XML. Each method is registered by protocol class and protocol method and when looked up by
the <tt>AMQMethodBodyFactory</tt> 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.</p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/qpid/Qpid+Design+-+Framing">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=28376&revisedVersion=2&originalVersion=1">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/qpid/Qpid+Design+-+Framing?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message