Atmosphere Cache

If you are using the Atmosphere framework for developing an Asynchronous Application, you end up using a broadcaster for delivering messages to its subscribed Atmosphere resources (clients). An application can subscribe to one or more Broadcasters to get notified about events from the server. A Broadcaster implements the publish/subscribe paradigm.

Losing Messages ?

Atmosphere fails to publish messages when there is a burst of activity. When the client is processing the first message the lookup returns null. Putting a pause/retry with some timeout (say 100 ms) only results in the client-finding it on the 2nd attempt.

One can also lose messages under the following scenarios:

  • When a connection gets closed (by a proxy, a timeout, the browser, the server), the Broadcaster.broadcast operation might still be in the process of delivering a message to that connection. Since that connection is closed, the message will be lost.
  • When a Browser reconnects, during the reconnection process messages can always be broadcasted and may not be delivered to that connection properly.

Broadcaster Cache comes to the rescue

Atmosphere provides cache mechanism for broadcast messages to cache them for a configured time to connected clients. It guarantees delivery of messages even when the client is disconnected for a short time during a communication glitch.

Acknowledging Delivery ensuring 100% Delivery

While the Cache mechanism reduces the chances of messages getting lost, there could still be scenarios where even after the message has been successfully written the client fails to receive it. When a websocket or fallback transport delivers a message, the send operation does not complete successfully until the message is safely stored in the sender’s data store. But if message is deleted from one datastore before it is successfully forwarded to and stored in the next data store then the message will be lost.

To ensure 100% delivery the Neova team implemented a Guaranteed Delivery system (GDS) on top of the Cache mechanism. GDS does this by having the client acknowledge the request back to the server. In case of a failure, the list of non acknowledged messages are re-sent until the client acknowledges them.

Neova has experienced Java Developers that have used Atmosphere framework comprehensively for a mission critical IoT Application.