background image

The Connection Factory

<< Running JMS Client Programs | Editing and Running the Programs >>
<< Running JMS Client Programs | Editing and Running the Programs >>

The Connection Factory

tut-install/javaeetutorial5/examples/bp-project/build.properties and change the
location of the javaee.home property each time you build or run a program on a different
system.
To create a new connection factory on jupiter, perform these steps:
1. From a command shell on jupiter, go to the directory
tut-install/javaeetutorial5/examples/jms/simple/producer/.
2. Type the following command:
ant create-local-factory
The create-local-factory target, defined in the build.xml file for the Producer example,
creates a connection factory named jms/JupiterConnectionFactory.
To create a new connection factory on earth that points to the connection factory on jupiter,
perform these steps:
1. From a command shell on earth, go to the directory
tut-install/javaeetutorial5/examples/jms/simple/producer/.
2. Type the following command:
ant create-remote-factory -Dsys=
remote-system-name
Replace remote-system-name with the actual name of the remote system.
The create-remote-factory target, defined in the build.xml file for the Producer example,
also creates a connection factory named jms/JupiterConnectionFactory. In addition, it sets
the AddressList property for this factory to the name of the remote system.
If you have already been working on either earth or jupiter, you have the queue and topic on
one system. On the system that does not have the queue and topic, type the following
command:
ant create-resources
When you run the programs, they will work as shown in
Figure 31­6
. The program run on
earth
needs the queue on earth only in order that the resource injection will succeed. The
connection, session, and message producer are all created on jupiter using the connection
factory that points to jupiter. The messages sent from earth will be received on jupiter.
Writing Simple JMS Client Applications
The Java EE 5 Tutorial · September 2007
932