Sending a message to a message-driven bean

Message-Driven Beans (MDB) are used in an asynchronous fashion. A client will create a message and then send it to a queue for processing. The MDB will effectively remove the message from the queue and act on it.

In this recipe, we will use the SalutationServlet to send a message to the queue each time a salutation is processed.

Getting ready

The process consists of two steps:

  1. Adding declarations for a queue factory and a message
  2. Adding code to actually send the message

    Review the SalutationApplication project as developed in the Accessing a session bean using dependency injection recipe. We will be modifying the SalutationServlet.

How to do it...

Start by adding declarations for a queue factory and a message ...

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.