4.2. A Simple Point-to-Point Example

This section describes the sending and receiving programs in a PTP example that uses the receive method to consume messages synchronously. This section then explains how to compile and run the programs, using the J2EE SDK 1.3.

4.2.1. Writing the PTP Client Programs

The sending program, SimpleQueueSender.java, performs the following steps:

1.
Performs a Java Naming and Directory Interface (JNDI) API lookup of the QueueConnectionFactory and queue
2.
Creates a connection and a session
3.
Creates a QueueSender
4.
Creates a TextMessage
5.
Sends one or more messages to the queue
6.
Sends a control message to indicate the end of the message stream
7.
Closes the connection in a finally block, automatically ...

Get Java™ Message Service API Tutorial and Reference: Messaging for the J2EE™ Platform now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.