2 Replies Latest reply on Mar 11, 2004 6:29 AM by remrick

    Accessing Clustered Servers via client code

    remrick

      Hello,

      There is quite a bit of discussion (and confusion I believe) in how to connect from a java client (whether it be a Java app, servlet or JSP) to a JBoss instance that happens to be clustered. I am seeing lots of discussion on just exactly how to create the proper JNDI Properties to pass to InitialContext().

      Before I embark on this adventure, I'd like to see if I can save myself (and others) time by getting clear and concise details on just exactly what is required. Can anyone help provide some guidance based on previous experience?

      Some questions I have now are:
      1) Can I simply leave my existing code as is as long as I am running the clustered JBoss instances (run -c all)?
      2) One example I saw in this forum used the following in relation to creating the InitialContext():

       p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
       p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      
       // to lookup on all servers, if apps2 goes down, it will lookup on apps3.
       //p.put(Context.PROVIDER_URL,"jnp://apps2:1100,jnp://apps3:1100");
      
       // to lookup on a specific server, not recommended as this does not make use
       // of the clustering (unless you have different groups of server that serve different
       // functions, and then you would still lookup on more than 1)
       p.put(Context.PROVIDER_URL,"jnp://apps3:1100");
      
      
       InitialContext jndiContext = new InitialContext(p);
      

      Is this needed? Seems like this makes more sense then doing nothing at all.

      3) How do I access from the client a SingletonService configured MBean?

      Unfortunately the JBoss Clustering documentation does not cover this topic and takes it for granted.

      Thanks,
      -Ron

        • 1. Re: Accessing Clustered Servers via client code
          kaobe

          Hi Ron,

          1. The code can be left as is. You just have to make the ejbs clustered (jboss.xml)
          2. I would prefer to give more than one server in the provider url, as in line 5. Or, if multicasting is possible from the client, leave the provider url empty, than a multicast is sent out and the first server to respond is the one you connect with.
          3. See answer to your other post.

          HTH,

          Peter

          • 2. Re: Accessing Clustered Servers via client code
            remrick

            Peter,

            Thanks for the help with this and the other post as well. I was hoping I was on the right track and it appears I'm close.

            Thanks,
            -Ron