Hi,
On Mon, May 20, 2013 at 6:23 PM, DL <
dennis...@gmail.com> wrote:
> Hi,
>
> I am wondering if it is possible to shadow the state of a primary CometD
> server to a secondary server. The goal of this is to allow clients'
> long-polling connections to be redirected to the backup without any
> requirement to re-handshake or re-subscribe.
>
> I have not begun to implement a solution but I have identified that it is
> possible to save incoming client data on handshake and subscribe and have
> that data passed to the secondary server. However I have not seen in the
> docs where it may be possible to manipulate the secondary server based on
> that information. For example, an in coming handshake creates a
> ServerSession for the client, and subsequently when the subscription for
> ChannelA occurs the ServerSession is added to the ServerChannel's list of
> subscribers. My goal would be to re-create those operations on the secondary
> server.
>
> So I have a couple of questions:
>
> Am I missing a more obvious (and hopefully easier) way to achieve the goal?
> Is the state re-creation possible or will I miss vital data changes that
> cannot be replicated via the public API?
>
> Basically if someone could tell me if I am completely insane to try this
> before I invest too much time I would appreciate it.
As often happens, you're asking directions on one solution that you
figured out, but you don't state the problem.
Mirroring the BayeuxServer state on another server does not make much sense.
The only purpose of a ServerSession is to communicate back to the
remote client. There is no point in maintaining one active in serverA,
and one mirrored in serverB which is actually unconnected and does
nothing.
Connection and subscriptions states live and are mastered by the client.
It's trivial for a well written client to rehandshake and resubscribe
with the new server and recreate in a blip the state that you want to
mirror. Really.
Now, you say that the requirement is to avoid rehandshaking and
resubscribing, but you don't say why you have this requirement.
A rehandshake is your friend, not an enemy you want to avoid.
What you may want to share across servers is application state, not
CometD state.
Imagine a chess game. If you share across servers the chessboard
positions, the player's names, turn and times, you probably have
enough to reconstruct the game no matter what happens.
If the server of one player crashes, the player will re-handshake on
another server, resubscribe as appropriate, and the server logic will
see the user again and "oh, you're back into this game... hey you have
this chessboard position, you have 1:15 left, and it's your turn."
We are working on a solution for sharing application state called
"Oort Objects", lookup the mailing list archives about.
I am going to push a branch soon for people to review and experiment.
--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.