10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Destination type is queue<br />

Reading message: This is message 1<br />

Running JMS Client Programs on Multiple Systems<br />

JMS client programs using the Application Server can exchange messages with each other when<br />

they are running on different systems in a network. <strong>The</strong> systems must be visible to each other by<br />

name (the UNIX host name or the Microsoft Windows computer name) and must both be<br />

running the Application Server. You do not have to install the tutorial examples on both<br />

systems; you can use the examples installed on one system if you can access its file system from<br />

the other system.<br />

Note – Any mechanism for exchanging messages between systems is specific to the <strong>Java</strong> <strong>EE</strong><br />

server implementation. This tutorial describes how to use the Application Server for this<br />

purpose.<br />

Suppose that you want to run the Producer program on one system, earth, and the<br />

SynchConsumer program on another system, jupiter. Before you can do so, you need to<br />

perform these tasks:<br />

■ Create two new connection factories<br />

■ Edit the source code for the two examples<br />

■ Recompile and repackage the examples<br />

Note – A limitation in the JMS provider in the Application Server may cause a runtime<br />

failure to create a connection to systems that use the Dynamic Host Configuration Protocol<br />

(DHCP) to obtain an IP address. You can, however, create a connection from a system that<br />

uses DHCP to a system that does not use DHCP. In the examples in this tutorial, earth can<br />

be a system that uses DHCP, and jupiter can be a system that does not use DHCP.<br />

Before you begin, start the server on both systems:<br />

1. Start the Application Server on earth.<br />

2. Start the Application Server on jupiter.<br />

Creating Administered Objects for Multiple Systems<br />

To run these programs, you must do the following:<br />

■ Create a new connection factory on both earth and jupiter<br />

■ Create a destination resource on both earth and jupiter<br />

Writing Simple JMS Client Applications<br />

Chapter 31 • <strong>The</strong> <strong>Java</strong> Message Service API 925

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!