Hello Cmilu, good question -- I have created a quickstart that demonstrates how to do this. I ll get it to a presentable form and share a link.
The theory goes like this: the service wrapped in singleton service looks up one @Remote @Clustered SFSB. Then the services wanting to use cluster-wide singleton get the reference from the service. If its not running on the same node, the remote EJB invocation is done.
Thank you for your answer. It's great, that there will be a quickstart concerning this matter - I'm looking forward to see it. I never tought of using a SFSB instead of a singleton in this case. If I understand it correctly, every service in the cluster (even if one fails, and another will be activated on some other node) will share the session state of the SFSB? Or it only guarantees me a cluster wide lock for the SFSB methods (that only one node at time will be handling the SFSB requests), and I have to manually manage my cluster-wide data with a custom inifnispan cache?
I don't think that is going to work. Everything will appear to work fine, but as soon as there is a failover of the singleton service, a new SFSB will be looked up and any state will have been lost.
Until we properly support @Clustered @Singleton beans, you're going to have to use an separate Infinispan cache to store shared singleton state (in which case, you can just have the singleton service return the remote stub of a SLSB).
We are facing a similar issue. We are migrating from JBoss 4.2.3 to 7.1.3 and previously we had services (annotated with @Service) which we have now changed to @Singleton beans, but we also need these singleton beans to work correctly on a cluster environment (only one node will have the active instance, the instance in another node will be activated if the master fails, etc).
In some cases, we are using Infinispan caches to replicate state across the nodes but that will not work well in all cases for us. So it is not currently possible to invoke methods on a cluster-wide singleton bean and be sure that it will be invoked only on the node which has the current active instance?
here is the POC for the cluster-wide Singleton Bean. There are things that need changing (see readme file) but might help you get started with your own implementation:
Of course, nothing beats proper support for @Clustered @Singleton beans but meanwhile...