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:

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

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

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