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.

ant delete-remote-factory<br />

Remember to delete the connection factory on both systems.<br />

You can also use Ant targets in the producer/build.xml file to delete the destinations and<br />

connection factories you created in “Creating JMS Administered Objects for the Synchronous<br />

Receive Example” on page 910. However, it is recommended that you keep them, because they<br />

will be used in most of the examples in Chapter 32, “<strong>Java</strong> <strong>EE</strong> Examples Using the JMS API.”<br />

After you have created them, they will be available whenever you restart the Application Server.<br />

To delete the class and JAR files for each program using NetBeans IDE, right-click each project<br />

and choose Clean.<br />

To delete the class and JAR files for each program using Ant, type the following:<br />

ant clean<br />

You can also stop the Application Server, but you will need it to run the sample programs in the<br />

next section.<br />

Creating Robust JMS Applications<br />

Creating Robust JMS Applications<br />

This section explains how to use features of the JMS API to achieve the level of reliability and<br />

performance your application requires. Many people choose to implement JMS applications<br />

because they cannot tolerate dropped or duplicate messages and require that every message be<br />

received once and only once. <strong>The</strong> JMS API provides this functionality.<br />

<strong>The</strong> most reliable way to produce a message is to send a PERSISTENT message within a<br />

transaction. JMS messages are PERSISTENT by default. A transaction is a unit of work into which<br />

you can group a series of operations, such as message sends and receives, so that the operations<br />

either all succeed or all fail. For details, see “Specifying Message Persistence” on page 934 and<br />

“Using JMS API Local Transactions” on page 940.<br />

<strong>The</strong> most reliable way to consume a message is to do so within a transaction, either from a<br />

queue or from a durable subscription to a topic. For details, see “Creating Temporary<br />

Destinations” on page 935, “Creating Durable Subscriptions” on page 936, and “Using JMS API<br />

Local Transactions” on page 940.<br />

For other applications, a lower level of reliability can reduce overhead and improve<br />

performance. You can send messages with varying priority levels (see “Setting Message Priority<br />

Levels” on page 934) and you can set them to expire after a certain length of time (see “Allowing<br />

Messages to Expire” on page 935).<br />

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

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

Saved successfully!

Ooh no, something went wrong!