Programming a JMS Application Using J2EE RI

In this section, you will develop a simple point-to-point application that sends and receives a text message. Although this code has not been written for any one particular JMS implementation, you will need to be aware that the mechanism for setting up the administered objects is implementation specific. Also, the JNDI names may be different for different J2EE environments.

J2EE RI Connection Factories

With the J2EE RI, you will use the default connection factory objects, named jms/QueueConnectionFactory and jms/TopicConnectionFactory.

Adding Destinations in J2EE RI

J2EE RI provides a command-line program called j2eeadmin to list, create, modify, and delete queues and topics. There is also a screen in the J2EE RI Application Deploy Tool that provides an interface to j2eeadmin for the same purpose.

Creating a Queue in J2EE RI

The point-to-point application uses a queue for communication. To create a queue do the following:

  1. Ensure that J2EE server is running.

  2. Use j2eeadmin or deploytool to create the queue.

Create a Queue Using j2eeadmin

To see the existing queues and topics, use the following:

j2eeadmin –listJMSDestination

The J2EE RI has a default queue predefined—jms/Queue.

To add a queue called jms/firstQueue, use the following:

j2eeadmin –addJMSDestination jms/firstQueue queue

The j2eeadmin command works silently, so to check that your queue has been created, run J2eeadmin -listJMSDestination once more. Figure 9.4 demonstrates the use of these two commands to create a queue called jms/firstQueue (this is the queue you will use in your first example).

Figure 9.4. Using j2eeadmin to add a JMS queue to J2EE RI.


Create a Queue Using deploytool

You can also use deploytool to list and add queues. Start up deploytool and select Server Configuration from the Tools menu, as shown in Figure 9.5.

Figure 9.5. Using deploytool to configure installation.


This will bring up the Configure Installation screen. Select JMS Destinations in the panel on left to display the screen in Figure 9.6.

Figure 9.6. Adding JMS destination in deploytool.


Click the Add button in the panel at bottom right titled JMS Queue Destinations and add a new queue called jms/firstQueue.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.20