How
WebSphere® Application Server Version 5.1 application clients
can access Java Message Service (JMS) resources provided by the
default messaging provider.
Both Java EE application clients and thin application clients
can access JMS resources provided by the default messaging provider:
- A Java EE
application client supports the client container that provides easy access
to services. The Java EE application client has the advantage of performing
a simple Java Naming and Directory Interface (JNDI) namespace
lookup to access the required service or resource.
- An application that uses a
WebSphere Application Server thin
client can use JNDI to obtain a connection factory from
WebSphere Application Server,
but the JNDI initial context must be set up by the application because no
container exists for doing this for the application. Although the application
can use the JMS API to explicitly create connection factories, it can still
do JNDI lookups.
In addition to both types of current
WebSphere Application Server application
clients,
WebSphere Application Server Version 5.1 Java EE
application clients can use their existing Version 5.1-style
JMS resources to access service integration bus destinations for the default
messaging provider. The link between Java EE application clients developed for
WebSphere Application Server Version 5.1,
and later versions of the application server, is defined by a
WebSphere MQ
client link object. One or more
WebSphere Application Server Version 5.1 clients can use the
same WebSphere MQ
client link.
As for other types of resources, a Java EE application client can use resource
environment references and resource references to use logical names to lookup
JMS resources.
- If you configure your Java EE application client to use resource
environment references (to resources bound into the server JNDI namespace),
you use the administrative console to define the resources.
- If you configure your Java EE application client to use resource
references (to local resources), you use the Application Client Resource Configuration
Tool (ACRCT) to define the resources. For more information
about ACRCT, see Starting the Application Client Resource Configuration
Tool and opening an EAR file
Figure 1. Message flows between
WebSphere Application Server Version 5.1 Java EE
application clients and a Version 6 or later application
server
Here is an example
of how a
WebSphere Application Server thin application
running in a J2SE environment can perform a JNDI lookup:
import javax.naming.*;
... Properties env = new Properties();
env.put(Context.PROVIDER_URL,"iiop://9.20.241.23:2809");
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext jndi = new InitialContext(env);
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory)jndi.lookup("tcfIBM");
The Context.PROVIDER_URL must be set to point to a
WebSphere Application Server and
the port server BOOTSTRAP_ADDRESS.