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

    Accessing Clustered Servers via client code

    Ron Emrick Newbie

      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