The ReliableClientMessage Class

The ActionScript class that knows how to send reliable messages and its Java counterpart are presented in Examples 5-24 and 5-25. Every outgoing ReliableClientMessage will have a unique sequential header, seqNo.

Example 5-24. ReliableClientMessage.as

package com.farata.messaging.messages{
   import mx.messaging.messages.AsyncMessage;

   [RemoteClass(alias="com.farata.messaging.messages.ReliableClientMessage")]
   public class ReliableClientMessage extends AsyncMessage   {

      static public var sequenceNo : int = 0;

      public function ReliableClientMessage(
         body:Object=null, headers:Object=null
      ) {
         if (!headers) {
            headers = [];
         }
         headers["seqNo"] = sequenceNo++;
         super(body, headers);
      }
   }
}

Example 5-25. ReliableClientMessage.java

package com.farata.messaging.messages;

import flex.messaging.messages.AsyncMessage;

public class ReliableClientMessage extends AsyncMessage {
}

Note

The only reason for creating a subclass of AsyncMessage.java is to have a way to separate regular AsyncMessage objects that don’t require special processing from the reliable ones.

Design of the No Client Message Left Behind policy

Figure 5-10. Design of the No Client Message Left Behind policy

Get Agile Enterprise Application Development with Flex now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.