Application Code
This section describes the application code, focusing on the application's JMS messaging functionality.
Topics covered by the basic JMS example, such as managing the connection, setting up the JNDI code for the administered objects, and creating the sender and receiver objects are not repeated here. The code descriptions focus on the following areas:
Implementing an asynchronous message listener. The asynchronous message listener receives customer inquiry messages and is installed on the server.
Linking a reply to a request message. The reply message, which contains the results of the customer inquiry, and is linked through message header fields to the original request.
Implementing a local transaction. The request message for customer information, and its reply message and acknowledgment are grouped into a local transaction.
Using a temporary queue. Since reply messages are only needed for the duration of a session, they are stored on a temporary queue by the requestor application.
Using a message selector. The message selector determines whether a customer request will be received, based on the Boolean expression specified by the selector.
Receiving messages on a second thread. The example includes a second session and a message consumer with a synchronous
receive() method that manages the reception of an administrator message on a second thread.