Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Understanding Message Services

A message service provider is responsible for providing a destination to which clients can send messages and from which message-driven beans (see "What is a Message-Driven Bean?") can receive messages for processing.

Using EJB 3.0, message-driven beans can only use a JMS message service provider.

Using EJB 2.1, message-driven beans can use a JMS or non-JMS service provider.

In either case, you can configure a message service provider by specifying message service provider classes or by using a J2EE Connector Architecture (J2CA) adapter.

For more information, see:

- "What Message Providers Can I use with My MDB?"

- "Configuring an EJB 3.0 MDB to Use a Non-J2CA Message Service Provider"

- "Configuring an EJB 2.1 MDB to Use a Non-J2CA Message Service Provider"

- "Configuring Message Services"

## What Message Providers Can I use with My MDB?

Using OC4J, you can use an MDB with the following types of message provider:

- Oracle Application Server JMS (OracleAS JMS) Provider: File-Based

- Oracle JMS (OJMS) Provider: Advanced Queueing (AQ)-Based

- J2EE Connector Architecture (J2CA) Adapter Message Provider

### Oracle Application Server JMS (OracleAS JMS) Provider: File-Based

OracleAS JMS is a native Java JMS provider implementation that provides file-based persistence and is tightly integrated with OC4J. It is the default JMS provider included with OC4J. Figure 2-2 shows how a client sends an asynchronous request directly to the OracleAS JMS queue or topic that is located internally within OC4J. The MDB receives the message directly from OracleAS JMS.

Figure 2-2 Demonstration of an MDB Interacting with an OracleAS JMS Destination

Description of "Figure 2-2 Demonstration of an MDB Interacting with an OracleAS JMS Destination"

If you do not access OracleAS JMS using the Oracle JMS Connector (see "J2EE Connector Architecture (J2CA) Adapter Message Provider"), be aware of the following restrictions:

- no support for two-phase commit (2PC)

For more information, see

- "Configuring an OracleAS JMS Message Service Provider"

- "Configuring an EJB 3.0 MDB to Use a Non-J2CA Message Service Provider"

- "Configuring an EJB 2.1 MDB to Use a Non-J2CA Message Service Provider"

- "Java Message Service (JMS)" in the Oracle Containers for J2EE Services Guide.

### Oracle JMS (OJMS) Provider: Advanced Queueing (AQ)-Based

Oracle JMS (OJMS) is the JMS interface to the Oracle Database Streams Advanced Queueing (AQ) feature. Oracle AQ is the Oracle database-integrated message queuing feature, built on the Oracle Streams information integration infrastructure that you install and configure within an Oracle database (see Figure 2-3).

Figure 2-3 Demonstration of an MDB Interacting with an OJMS Destination

Description of "Figure 2-3 Demonstration of an MDB Interacting with an OJMS Destination"

An MDB uses OJMS as follows:

1. The MDB opens a JMS connection to the database using a data source with a username and password. The data source represents the Oracle JMS provider and uses a JDBC driver to facilitate the JMS connection.

2. The MDB opens a JMS session over the JMS connection.

3. Any message for the MDB is routed to the `onMessage` method of the MDB.

At any time, the client can send a message to the Oracle JMS topic or queue on which MDBs are listening. The Oracle JMS topic or queue is located in the database.

Before using Oracle JMS, you must create the appropriate queue or table in the database.

Note: MDBs only work with certain versions of the Oracle database. See the certification matrix in the JMS chapter of the Oracle Containers for J2EE Services Guide for more information.

For more information, see:

- "Configuring an OJMS Message Service Provider"

- "Configuring an EJB 3.0 MDB to Use a Non-J2CA Message Service Provider"

- "Configuring an EJB 2.1 MDB to Use a Non-J2CA Message Service Provider"

- Oracle Streams Advanced Queuing User's Guide and Reference

- "Java Message Service (JMS)" in the Oracle Containers for J2EE Services Guide

### J2EE Connector Architecture (J2CA) Adapter Message Provider

OC4J provides a JMS Connector: a generic Java Message Service (JMS) J2CA resource adapter that integrates OC4J with OracleAS JMS and OJMS message service providers, as well as non-Oracle JMS providers as Table 2-7 shows.

Table 2-7 Oracle JMS Connector Support for JMS Message Service Providers

JMS Provider | Version
--- | ---
OracleAS JMS | all
OJMS | all
IBM WebSphere MQ-based JMS | Server Version 5.3 and 6.0
TIBCO Enterprise for JMS | 3.1.0
SonicMQ | 6.0

You can use other J2CA-compliant adapters with OC4J to integrate with other types of enterprise information systems (EIS).

Note: Oracle recommends that newer JMS applications be deployed using the J2CA 1.5 Resource Adapter mandated by the J2EE 1.4 standard.

Using a J2CA adapter, you can access other JMS and non-JMS message service providers as Figure 2-4 shows. In this architecture, the client does not access a queue or topic directly. Instead, to send a message to an EIS by way of a J2CA adapter, you:

1. Obtain a `javax.resource.cci.ConnectionFactory`.

   If the EIS is a JMS message service provider, there will likely be connection factory choices for queue or topic. For example, the Oracle JMS Connector offers a `QueueConnectionFactory` and a `TopicConnectionFactory`.

2. Use the factory to obtain a `javax.resource.cci.Connection`.

3. Use the connection to obtain a `javax.resource.cci.Interaction`.

4. Configure the interaction and use `Interaction` method `execute` to send the message.

Figure 2-4 Demonstration of an MDB Interacting with a J2CA JMS Destination

Description of "Figure 2-4 Demonstration of an MDB Interacting with a J2CA JMS Destination"

From the perspective of OC4J, J2CA is only used as a means of accessing a message service provider for use with message-driven beans.

For more information, see:

- "Configuring a Message Service Provider Using J2CA"

- "Configuring an EJB 3.0 MDB to Use a J2CA Message Service Provider"

- "Configuring an EJB 2.1 MDB to Use a J2CA Message Service Provider"

- "Introducing Oracle JMS Support and Generic JMS Resource Adapter" in the Oracle Containers for J2EE Resource Adapter Administrator's Guide

- "Overview: Administering Resource Adapters" in the Oracle Containers for J2EE Resource Adapter Administrator's Guide

Note: For a complete code example of configuring a J2CA message service provider resource adapter and MDB application, see `http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-gjra-with-oracleasjms/doc/how-to-gjra-with-oracleasjms.html`.