Chapter 4. Messaging and developing MDBs

 

This chapter covers

  • Introducing messaging concepts
  • Building a message producer using JMS
  • Developing MDBs

In this chapter we’ll take a closer look at developing message-driven beans (MDBs) as well as provide you with an overview of the concepts and technologies these powerful EJB 3 components build on. First we’ll introduce you to basic messaging concepts, and then we’ll explore the Java Messaging Service (JMS) by creating a message producer. Finally, we’ll take a look at MDBs, the EJB 3 answer to messaging.

You should gain an understanding of messaging and JMS before diving into MDB for two reasons. First, most MDBs you’ll encounter are glorified JMS message consumers implementing JMS interfaces (such as javax.jms.MessageListener) and using JMS components (such as javax.jms.Message). Second, for most solutions with MDB your messaging will involve much more than simply consuming messages. For the simplest of these tasks, such as sending messages, you’ll have to understand JMS. This chapter assumes a basic familiarity with JMS and we offer only a brief description of it.

If you’re comfortable with messaging and JMS, feel free to skip to the sections on MDBs. It is good to reinforce what you know from time to time, though, so you just might want to quickly jog through the first few sections with us anyway.

4.1. Messaging concepts

4.2. Introducing Java Messaging Service

4.3. Working with message-driven beans

4.4. MDB best practices

4.5. Summary