Handling a map-based message

The MapMessage interface supports a message consisting of a set of mapped key/value pairs. This is similar to the Java HashMap class where a key, such as a name, can be assigned a value, such as a telephone number. It allows this type of information to be transferred as a set of key/value pairs. In this recipe we will develop an application that illustrates their use.

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 MapMessage which include:

  1. Creating a MapMessage using the createMapMessage method
  2. Writing key/value pairs to the MapMessage
  3. Sending the message

How to do it...

Create a Queue named ...

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.