|
In IBM WAS ND V6, a naming server exists in every server process (appserver, Node Agent, and Deployment Manager). You can bootstrap your client to any of these naming servers. Usually servlets, EJB clients, and J2EE clients start their bootstrap from their local appserver and end up on the server where the objects are found.
For Java clients, you can bootstrap to more than one naming server on different Node Agents.
Example 3-3 Java client bootstrapping
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); prop.put(Context.PROVIDER_URL, "corbaloc::host1:2809,:host2:2809"); Context initialContext = new InitialContext(prop); try { java.lang.Object myHome = initialContext.lookup("cell/clusters/MyCluster/MyEJB"); myHome = (myEJBHome) javax.rmi.PortableRemoteObject.narrow(myHome, myEJBHome.class); } catch (NamingException e) { }
The client tries the bootstrap servers on host1 and host2 automatically until it gets an InitialContext object. The order in which the bootstrap hosts are tried is not guaranteed.
The Node Agent is not workload managed. If a client gets a cached InitialContext object and that Node Agent is unavailable, the InitialContext object will not automatically failover to another Node Agent, so the lookup with this InitialContext object fails. In order to avoid this problem, disable the cache in your client by supplying the following property when initializing the naming context:
prop.put(PROPS.JNDI_CACHE_OBJECT, PROPS.JNDI_CACHE_OBJECT_NONE)
Where PROPS.JNDI_CACHE_OBJECT is a Java constant defined in com.ibm.websphere.naming.PROPS.
Or more conveniently by setting the Java command line property as:
java -Dcom.ibm.websphere.naming.jndicacheobject=none MyClient
Using Node Agents as bootstrap servers is not recommended because they are not workload managed. Because appservers in a cluster are workload managed, you should use appservers as bootstrap servers instead as follows:
prop.put(Context.PROVIDER_URL, "corbaloc::host1:9810,:host1:9811, :host2:9810, :host2:9811");
This discussion is only relevant for naming lookup (read) operations. If your application is binding (writing), a failure occurs if the Node Agent is unavailable, because the Node Agent coordinates the binding process.
Refer to IBM WebSphere V6 Scalability and Performance Handbook, SG24-6392 for more information about bootstrapping.