Suitable JMS connection factories and references to JMS
queues or topics might be obtained programmatically without using
JNDI. Alternatively, full JNDI support might be obtained from the
Thin Client for EJB with WebSphere® Application Server.
Procedure
- To obtain suitable connection factories programmatically,
without using JNDI, use code similar to that shown in the following
example:
import com.ibm.websphere.sib.api.jms.*;
...
JmsConnectionFactory jmsCF =
JmsFactoryFactory.getInstance().createQueueConnectionFactory();
jmsCF.setBusName("myBus");
jmsCF.setProviderEndpoints("1.2.3.4");
To obtain a suitable reference to a JMS queue or topic
programmatically, use code similar to that shown in the following
example:
JmsQueue jmsQ = JmsFactoryFactory.getInstance().createQueue("myQueue");
For
further information, see the
JmsFactoryFactory class
API documentation available with
WebSphere Application Server.
- To obtain full JNDI support from the Thin Client for EJB
with WebSphere Application Server:
- Include the /runtimes/com.ibm.ws.ejb.thinclient_8.5.0.jar file
in the compile and runtime classpaths for your enterprise application
as described in Installing and configuring the Thin Client for JMS with WebSphere Application Server.
- Use the following code to create a suitable Initial
Context, substituting the server IP address and port as appropriate:
import javax.naming.*;
...
Properties env = new Properties();
env.put(Context.PROVIDER_URL,"iiop:
//<server IP address>:<server bootstrap address port>");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext ctx = new InitialContext(env);
In certain
situations, for example when running with a Sun JRE, an additional
ORB jar is also required. For additional information about when this
jar is required, see
Running the IBM Thin Client for Enterprise JavaBeans (EJB).