Obtaining WebSphere MQ JMS resources in the thin client environment

A stand-alone Java™ SE JMS thin client application that connects to an external WebSphere® MQ queue manager can get administratively-created WebSphere MQ messaging provider JMS resources from the WebSphere Application Server Java Naming and Directory Interface (JNDI) namespace.

Procedure

  1. To obtain WebSphere MQ messaging provider JMS resources from the WebSphere Application Server JNDI namespace in the thin client environment, include the following jar files in the runtime classpath of your application:
    • A copy of the /runtimes/com.ibm.ws.ejb.thinclient_8.5.0.jar file.
    • A copy of the /runtimes/com.ibm.ws.messagingClient.jar file.
    • WebSphere MQ client jar files, which must be obtained from the WebSphere MQ product.
  2. 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 the Thin Client for EJB with WebSphere Application Server information and Running the IBM Thin Client for Enterprise JavaBeans (EJB).