Handling an object-based message

This is the last in the series of recipes illustrating how to send an order type message. In this recipe we will use a simple Java class called Order to represent the order and an ObjectMessage object to encapsulate the Order object. Since an order is best represented as a class, the ObjectMessage is the preferred technique for sending an order.

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 an ObjectMessage which include:

  1. Creating an ObjectMessage using the createObjectMessage method
  2. Attaching the object to the ObjectMessage using the setObject method
  3. Sending the message

How to do it... ...

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.