Overview

OpenJMS uses JNDI (the Java Naming and Directory Interface ), to make connection factories, topics, and queues available to clients.

OpenJMS can be configured to use an embedded JNDI provider, or an external JNDI provider.

Configuring the embedded JNDI provider

By default, OpenJMS uses an embedded JNDI provider. This is specified by the < ServerConfiguration > element in the $OPENJMS_HOME/config/openjms.xml configuration file:

       
  <ServerConfiguration embeddedJNDI="true"/>
        
        

Connecting to the embedded JNDI provider

The following code fragment demonstrates how to connect to the embedded JNDI provider:

    Hashtable properties = new Hashtable();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, 
                   "org.exolab.jms.jndi.InitialContextFactory");
    properties.put(Context.PROVIDER_URL, "<provider-url>");

    Context context = new InitialContext(properties);
          

In the above, the provider-url is the embedded JNDI provider URL. This is connector specific. Refer to the Connector documentation for details.

Configuring an external JNDI provider

To configure an external JNDI provider, the $OPENJMS_HOME/config/openjms.xml configuration file needs to be modified:

  1. The embeddedJNDI attribute of the < ServerConfiguration > element needs to be set to "false"
  2. The < JndiConfiguration > element needs to be specified.

    This lists the connection properties of the external provider.

E.g:
  <ServerConfiguration embeddedJNDI="false" />

  <JndiConfiguration>
    <property name="java.naming.factory.initial"
              value="com.sun.jndi.rmi.registry.RegistryContextFactory" />
    <property name="java.naming.provider.url"
              value="rmi://localhost:1099" />
  </JndiConfiguration>