12.5. Java Naming and Directory Interface

We skipped over some of the setup code in the previous example so that we could concentrate on the messaging functionality. Whenever clients and servers need to communicate, there must be a way for the side initiating the connection to locate the other side. With a typical sockets application, this is done via a well-known port number. For JMS, as well as several other J2EE APIs, the Java Naming and Directory Interface (JNDI) is used to facilitate this location. A service can register itself in a JNDI registry; clients can then look up the service by name. The process of using JNDI is straightforward:

  • The server obtains a connection to the JNDI registry via the call getInitialContext().

  • Using the initialContext ...

Get J2EE™ and JAX™: Developing Web Applications and Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.