registration and declarations to the hub in a single atomic operation

Yohann Granet yohann.granet at oamp.fr
Thu Feb 12 08:40:05 PST 2009


Hi,


I just wanted to expose my point of view concerning the way by which 
JSAMP clients register them and declare their metadatas and subscriptions.

Actually I think it's a pity that these operations cannot be done in an 
atomic manner...


Of course, a priori, it seems more flexible to allow a client to 
register and to do its declarations later... (((why to do that?...)))
but, for me, gathering these operations in a single method would present 
2 real advantages:


1) a more simple way to register a client: 1 method instead of 4 for now.

something like
    hubConnection = clientProfile.registerCallableClient(this, 
metadatas, subscriptions);

instead of
    hubConnection = clientProfile.register();
    hubConnection.setCallable(this);
    hubConnection.declareMetadata(metadata);                
    hubConnection.declareSubscriptions(subscriptions);

(and if a client needs to change its metadatas or subscriptions?... 2 
solutions:
    - unregister, then register again (a client with new informations 
can be considered as a new client)
    - create new "updateMetadatas(Metadatas metadatas)" and 
"updateSubscriptions(Subcriptions subscriptions)" methods.
)   


2) a concurrency-safe way to declare a client to the hub!!!
indeed, in case of several clients registering them and declaring 
metadatas and subscriptions to the hub problems can occur.
see my example:
I work on an package manager intended to launch applications and 
retransmit them previously received messages. So my package manager have 
to listen and react to hub events (subscriptions, unregister events) in 
order to maintain its own running clients list, to know if there is 
already registered client having subscribed for every asked MType.
When launching several applications simultaneously, if a thread (in the 
hub) in charge of registration and declarations for a new client "A" is 
interrupted by another thread in charge of doing the same for a client 
"B", then when the subscription event caused by "B" is launched my 
package manager refreshes its client list and then gets incomplete 
informations concerning application "A" (empty metadatas and/or 
subscriptions).

OK, OK, it's a very particular case but the same type of problem can 
occur to anyone.
problem that could be avoid if the registration and declarations 
operations were performed in an atomic way.


some comments or arguments?


    Yohann Granet



More information about the apps-samp mailing list