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 ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

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