Sun Java System Message Queue 3.7 UR1 Technical Overview

Chapter 5 Message Queue and J2EE

The Java 2 Platform, Enterprise Edition (J2EE platform) is a specification for a standard server platform hosting multi-tier and thin client enterprise applications. One of the requirements of the J2EE platform is that distributed components be able to interact through reliable, asynchronous messaging. This interaction is enabled through the use of a JMS provider. In fact, Message Queue is the reference JMS implementation for the J2EE platform.

This chapter explores the ramifications of implementing JMS support in a J2EE platform environment. The chapter covers the following topics:

For additional information about using Message Queue as a JMS provider for J2EE compliant application servers, see Chapter 17, JMS Resource Adapter Property Reference, in Sun Java System Message Queue 3.7 UR1 Administration Guide.

JMS/J2EE Programming: Message-Driven Beans

In addition to the general JMS client programming model introduced in Chapter 2, Client Programming Model, there is a more specialized adaptation of a JMS client used in the context of J2EE platform applications. This specialized client is called a message-driven bean and is one of a family of Enterprise JavaBeans (EJB) components described in the EJB 2.0 (and later) Specification (

Message-driven beans provide asynchronous messaging; other EJB components (session beans and entity beans) can only be called synchronously, through standard EJB interfaces. However, enterprise applications often need asynchronous messaging, to allow server-side components to communicate without tying up server resources. Any application whose server-side components must respond to application events needs an EJB component that can receive and consume messages without being tightly coupled to the message producer. In enterprise applications, this capability must also scale under increasing load.

A message-driven bean (MDB) is an EJB component supported by a specialized EJB container, that provides distributed services for the components it supports.

Figure 5–1 Messaging with MDBs

Diagram showing JMS message producers sending messages to consuming
MDB instances in a J2EE environment.

J2EE Application Server Support

In J2EE architecture, EJB containers are hosted by J2EE application servers. An application server provides resources needed by the various containers: transaction managers, persistence managers, name services, and, in the case of messaging and MDBs, a JMS provider.

In the Sun Java System Application Server, JMS messaging resources are provided by Sun Java System Message Queue:

For future releases of the Application Server, Message Queue will be plugged into the application server using standard resource adapter deployment and configuration methods.

For information about J2EE architecture, see the J2EE Platform Specification located at

JMS Resource Adapter

A resource adapter is a standardized way of plugging additional functionality into an application server that complies with J2EE 1.4. The standard, defined by the J2EE Connector Architecture (J2EECA) 1.5 specification, allows an application server to interact with external systems in a standard way. External systems can include enterprise information systems (EIS), as well as messaging systems: for example, a JMS provider. Message Queue includes a JMS resource adapter that allows application servers to use Message Queue as a JMS provider.

Plugging a JMS resource adapter into an application server allows J2EE components deployed and running in the application server to exchange JMS messages. The JMS connection factory and destination administered objects needed by these components can be created and configured using J2EE application server administration tools.

Other administrative operations, however, such as managing a broker and physical destinations, are not included in the J2EECA specification and can be performed only through provider specific tools.

The Message Queue resource adapter is integrated in the Sun J2EE 1.4 application server. However, it has not yet been certified with any other J2EE 1.4 application servers.

The Message Queue resource adapter is a single file (imqjmsra.rar) located in a directory that depends on the operating system (see Chapter 17, JMS Resource Adapter Property Reference, in Sun Java System Message Queue 3.7 UR1 Administration Guide). The imqjmsra.rar file contains the resource adapter deployment descriptor (ra.xml) as well as the JAR files needed by the application server in order to use the adapter.

You can use the Message Queue resource adapter in any J2EE-1.4-compliant application server by following the resource adapter deployment and configuration instructions that come with that application server. As commercial J2EE 1.4 application servers become available and the Message Queue resource adapter is certified for those application servers, Message Queue documentation will provide specific information on the relevant deployment and configuration procedures.