The file jbm-jms.xml on the server classpath contains any JMS
Queue, Topic and ConnectionFactory instances that we wish to create and make
available to lookup via the JNDI.
A JMS ConnectionFactory object is
used by the client to make connections to the server. It knows the location of
the server it is connecting to, as well as many other configuration parameters.
In most cases the defaults will be acceptable.
We'll deploy a single JMS Queue
and a single JMS Connection Factory instance on the server for this example but
there are no limits to the number of Queues, Topics and Connection Factory
instances you can deploy from the file. Here's our configuration:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
We deploy one ConnectionFactory
called ConnectionFactory and bind it in just one place in JNDI as
given by the entry element.
ConnectionFactory instances can be bound in many places in JNDI if you require.
Note
The JMS connection factory
references a connector called netty. This is a reference to a connector
object deployed in the main core configuration file jbm-configuration.xml which defines the transport and
parameters used to actually connect to the server.
JNDI configuration
When using JNDI from the client
side you need to specify a set of JNDI properties which tell the JNDI client
where to locate the JNDI server, amongst other things. These are often
specified in a file called jndi.properties on the client classpath, or you can specify them
directly when creating the JNDI initial context. A full JNDI tutorial is
outside the scope of this document, please see the Sun
JNDI tutorial for more information on how to use JNDI.
For talking to the JBoss JNDI
Server, the jndi properties will look something like this:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://myhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Where myhost is the hostname or IP address of the JNDI server.
1099 is the port used by the JNDI server and may vary depending on how you have
configured your JNDI server.
In the default standalone
configuration, JNDI server ports are configured in the jbm-jboss-beans.xml file where the JNDIServer bean is
confgured, here's a snippet from the file:
1099
localhost
1098
localhost
Note
If you want your JNDI server to
be available to non local clients make sure you change it's bind address to
something other than localhost!