O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling a string-based message

In this recipe, we will use a TextMessage to send an order to an MDB. The TextMessage interface uses a String object to hold the order. We will use the java.util.Scanner class to parse the order information from this string.

Getting ready

The essential structure of a servlet used to generate a message was introduced in the introduction. Here we will address the unique elements of creating and using a TextMessage which include:

  1. Creating a TextMessage using the createTextMessage method
  2. Creating a string containing the message
  3. Sending the message

How to do it...

Create a Queue named jms/TextQueue and a QueueConnectionFactory named jms/TextFactoryPool as described in the introduction. Next, create a Java EE application called ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required