1 Reply Latest reply on Jan 30, 2007 2:04 PM by brian.stansberry

    sibgleton service (cluster-wide)

    mhsheikh

      I need to have a service that runs on one and only node, but is accessible from any node. Instead of using a HASingleton (which I can successfully deploy but have problems to invoke it from nodes other than primary), I decided to do this:
      I use @Service to create a service POJO which is guranteed to be singleton per node. Now, when each node needs to invoke a method on the service, it looks up HA-JNDI for a predefined key (say MySingletonService). If it can't find it, it binds the remote stub of its local service EJB (../ServiceEJBName/remote) to the key (MySingletonService) in HA-JNDI (and this node becomes the primary for the service). Otherwise, it uses the stub retrieved from JNDI (stub to primary node's service EJB). This way, I expect that any node that uses the stub, invokes operation on the primary node's service POJO.
      The problem is that, when I want to invoke a method from the primary node, everything works fine. But from other nodes, I get the correct stub object, but it's class name is not correct (e.g., when I get the stub in primary node, its hashcode is X and it's class name is Proxy101, but when I get the sub from another node, although the hashCode is still X, the calss name is Proxy103 on node B, Proxy 107 on node C, etc).
      When I invoke a method on this hashcode, it seems that it's not invoked on the primary service POJO but on the local service POJO.
      I'd appreciate any help.

        • 1. Re: sibgleton service (cluster-wide)
          brian.stansberry

          If the invocation goes through, but not on the remote server, what you're probably seeing is the usual JBoss behavior of detecting the presence of the bean in VM and optimizing to a local call.

          I believe this is implemented via the org.jboss.aspects.remoting.IsLocalInterceptor. If you post on the EJB3 forums they may be able to give you some advice on how to work around that; e.g. configure your EJB so that interceptor isn't in the client-side interceptor stack.