J2EE 1.3 reference server, which was only available as a beta release at publication of this book, is a reference implementation from Sun Microsystems of the various J2EE APIs defined in the J2EE 1.3 specification. The reference implementation supports EJB 2.0, Servlet 2.3, JSP 1.2, and JMS 1.02 (which is mandatory in this specification). The beta version is available under the early access program and can be downloaded from http://java.sun.com/j2ee. The reference implementation is fully compliant with the JMS 1.02 specification and supports both Pub/Sub and PTP messaging models.
J2EE server can be started by running the file j2ee.bat or j2ee.sh file available in the bin directory under the J2EE reference implementation installations. Make sure that you have set the environmental variables J2EE_HOME and JAVA_HOME before you start the server. By default, the server listens on the following ports for various services:
8000 — For HTTP connections, which, can be altered by editing the web.properties file in the config directory under the J2EE installation
7000 — For HTTPS connections, which can be altered by editing the web.properties file in the config directory under the J2EE installation
1050 — For JNDI lookups, which can be altered by editing the orb.properties file in the config directory under the J2EE installation
The reference implementation defines two JMS-related properties files in the config directory.
jms_client.properties
This file contains the various properties required by the JMS clients for JNDI lookup, connecting to the server, preferred communication protocol, and logging level.
jms_service.properties
This file defines the various properties required for the JNDI server for implementing durable subscriptions and message redelivery.
The administration tool is a command-line utility for managing various resources on the server. This tool can be run by using the j2eeadmin.bat or j2eeadmin.sh file that can be found in the bin directory. The tool can be used for:
Adding, listing, removing JDBC drivers
Adding, listing, removing JDBC data sources
Adding, listing, removing JDBC XA data sources
Adding, listing, removing JMS destinations
Adding, listing, removing JMS connection factories
Adding, listing, removing connector factories
We will have a look at some of the commands related to JMS:
Adding a queue named myQueue | j2eeadmin -addJmsDestination myQueue queue |
Adding a topic names myTopic | j2eeadmin -addJmsDestination myTopic topic |
Adding a queue connection factory named QCFactory | j2eeadmin -addJmsFactory QCFactory queue |
Adding a topic connection factory named TCFactory | j2eeadmin -addJmsFactory TCFactory topic |
Listing all the configured JMS destinations | j2eeadmin -listJmsDestination |
Listing all the configured JMS connection factories | j2eeadmin -listJmsFactory |
Removing a JMS destination named myQueue | j2eeadmin -removeJmsDestination myQueue |
Removing a JMS connection factory named QCFactory | j2eeadmin -removeJmsFactory QCFactory |
We will be storing the Administered objects in the internal JNDI namespace provided by the J2EE reference implementation.
Type the following commands to add a topic named myTopic and a topic connection factory named TCFactory in the command window:
C:\ProJMS\AppendixA> j2eeadmin -addJmsDestination myTopic topic C:\ProJMS\AppendixA> j2eeadmin -addJmsFactory TCFactory topic
For running the client first start the J2EE server as explained earlier. Now invoke the Java interpreter on the class PortableJMSClient with all the required classes in the classpath and passing the location of the JMS client properties file as a system property using the -D option.
The required JAR files are:
j2ee.jar — This JAR file contains all the required classes for JNDI and JMS
The following property should be passed to the program using the -D option for the Java interpreter:
Property name — jms.properties.
Property value — <J2EE_HOME>\config\jms_client.properties. Where <J2EE_HOME> is the directory under which the J2EE reference implementation is installed
The figure below shows the JMS client running against the J2EE reference implementation: