1 2 Previous Next 16 Replies Latest reply on Jul 9, 2013 11:01 AM by pgmjsd

    Singleton cluster service

    pavel.orehov

      Hi,

       

      There was something called Clustered Singleton Service in previous JBoss versions (

      http://docs.jboss.org/jbossclustering/cluster_guide/5.1/html-single/index.html#d0e1209).

       

      Is there is something like that in AS 7 ?

       

      Thanks,

      Pavel

        • 1. Re: Singleton cluster service
          pavel.orehov

          Still looking for the answer.

          • 2. Re: Singleton cluster service
            jaikiran
            • 3. Re: Singleton cluster service
              pferraro

              There's an example of using SingletonService here:

              https://github.com/jbossas/jboss-as/tree/master/testsuite/integration/clust/src/test/java/org/jboss/as/test/clustering/cluster/singleton/service

               

              In summary, you can use SingletonService to decorate a Service<?> such that the service will only ever be started on one node in a cluster at any given time.

              • 4. Re: Singleton cluster service
                radzish

                Hi Paul,

                 

                This example works fine bu failes when application is redeployed. Service is failed to start second time. Can you suggest how to fix it ?

                • 5. Re: Singleton cluster service
                  pgmjsd

                  Paul,

                   

                  I've got an AS5 app that use a POJO service bean cluster singleton, just like Pavel (and others)l.   I looked over this example, and I'm not sure how I would use that in the place of what I now have in AS5:  A cluster singleton service that can be accessed from any node on the cluster by looking it up in HAJNDI.  

                   

                  1. How do you access this cluster singleton MSC bean from other nodes in the cluster?
                  2. It looks like the MSC bean has only the one getValue() method that can be called.   AS5 POJO service beans have regular EJB-like interfaces with many methods.   Is the MSC bean supposed to register a remote interface to a singleton EJB somehow?

                  All I realy need is a way to get a remote interface to a singleton on the cluster.

                  • 6. Re: Singleton cluster service
                    wdfink

                    You may have a look into the quickstart overview and this cluster-ha-singleton-ejb quickstart

                    • 7. Re: Singleton cluster service
                      pgmjsd

                      I've cloned that repo and switched to the cluster-hasingleton-ejb branch.  I get the part where you are using an SLSB remote interface called ServiceAccess to provide access to the service,  and I see how ServiceAccessBean is locating the real service and delegating to it.   This is exactly what I'm doing in my app, except the inner service is a POJO Service, which the SLSB looks up in HA-JNDI.

                       

                      I'm not sure this answers my second question.   In this example EnvironmentService is the cluster singleton, right?   It only has a 'getValue()' method as far as I can tell.    Can it have other methods that are called from ServiceAccessBean?  In AS5, you could make a POJO service with an interface that had as many methods as you wanted.

                      • 8. Re: Singleton cluster service
                        pferraro

                        The EnvironmentService referenced in the quickstart is a simple Service<String> whose getValue() returns a String.  The target type of a service can be whatever you want, e.g. Service<ServiceAcccess>.

                        • 9. Re: Singleton cluster service
                          pgmjsd

                          Thanks Paul.   So the service can be sort of a 'provider'... okay, but how would it return something that other nodes on the cluster can call?    Would the MBean implementation implement the business interface as well as the Service<?> interface? I guess I don't really understand the 'service' concept that well.   It seems very different from the AS 5 POJO service definition.

                          • 10. Re: Singleton cluster service
                            pgmjsd

                            I read this in the Javadoc for org.jboss.msc.service.Service<T>:

                            The value type specified by this service is used by default by consumers of this service, and should represent the public interface of this service, which may or may not be the same as the implementing type of this service.

                            So, that means the service MBean can implement another interface and return itself via getValue()?

                            • 11. Re: Singleton cluster service
                              pferraro

                              Correct.

                              • 12. Re: Singleton cluster service
                                pgmjsd

                                Thanks Paul.   One more thing, just to make sure I understand before I go off and try it ...

                                 

                                public class MyServiceBean implements implements Service<MyInterface>, MyInterface {
                                ...
                                   public MyBusinessInterface getValue() { return this; }
                                ...
                                }
                                

                                 

                                The return value will be remotely invokeable from all other nodes in the cluster?

                                • 13. Re: Singleton cluster service
                                  wesjanik

                                  Hi Joshua - did you ever resolve this issue?

                                   

                                  I'm struggling with the same scenario.  I'm looking for a way to return something akin to a remote EJB proxy pointing specifically to the node the singleton service is running on.  However, if I understand the JBoss remote proxies correctly, they purposely don't point to the node they were created on.  In other words, if MyServiceBean in your example above looks up a remote reference to an EJB and returns that reference from getValue, that proxy isn't guaranteed to invoke the bean on the singleton node when it is used on some other node in the cluster.

                                   

                                  In essense, I'm trying to find a way to get something useful out of getValue that will allow me to invoke methods on an EJB guaranteed to be within the same node as the singleton service.  Any ideas are greatly appreciated.

                                  • 14. Re: Singleton cluster service
                                    pgmjsd

                                    I have not had a chance to fully try out what Paul suggested.   Busy with other things at the moment.

                                    1 2 Previous Next