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.
With the J2EE RI, you will use the default connection factory objects, named jms/QueueConnectionFactory and jms/TopicConnectionFactory.
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.
The point-to-point application uses a queue for communication. To create a queue do the following:
Ensure that J2EE server is running.
Use j2eeadmin or deploytool to create the queue.
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).
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.
This will bring up the Configure Installation screen. Select JMS Destinations in the panel on left to display the screen in Figure 9.6.
Click the Add button in the panel at bottom right titled JMS Queue Destinations and add a new queue called jms/firstQueue.
3.17.79.20