OverviewOpenJMS 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 providerBy 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 providerThe 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 providerTo configure an external JNDI provider, the $OPENJMS_HOME/config/openjms.xml configuration file needs to be modified:
<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> |