2 MDB Life Cycle

Examine the phases in the life cycle of an MDB instance and how you can configure an MDB to control the life cycle.

This chapter includes the following sections:

Overview

An MDB implements loosely coupled or asynchronous business logic in which the response to a request need not be immediate. A message-driven bean receives messages from a JMS queue or topic, and performs business logic based on the message contents. It is an asynchronous interface between EJBs and JMS.

All instances of a message-driven bean are equivalent—the EJB container can assign a message to any MDB instance. The container can pool these instances to allow streams of messages to be processed concurrently.

The EJB container interacts directly with a message-driven bean—creating bean instances and passing JMS messages to those instances as necessary. The container initially populates each MDB free pool according to initial-beans-in-free-pool, which defaults to 0. It creates additional instances on demand and may remove instances during operation.

MDBs and Concurrent Processing

MDBs support concurrent processing for both topics and queues. On an Oracle WebLogic Server instance, each MDB deployment maintains one or more MDB instance pools, also known as free pools, that hold MDB instances not currently servicing requests. The max-beans-in-free-pool setting, the Work Manager or execute-thread configuration, and the message-processing mode determine the maximum number of concurrent MDB invocations for each pool.

For more information about topics and queues, see MDBs and Messaging Models.

See Tuning Message-Driven Beans in Tuning Performance of Oracle WebLogic Server.

The number of free pools associated with an MDB deployment depends on the type of destination the MDB deployment is connected to. Typically, an MDB deployment is associated with a single free pool on each Oracle WebLogic Server instance that hosts the deployment. However, on each Oracle WebLogic Server instance that hosts the deployment, an MDB deployment connected to a WebLogic JMS distributed destination might have one free pool for each physical destination associated with the distributed destination. The number of free pools is automatically determined by the EJB container; and, for MDBs associated with a JMS destination, each MDB free pool always corresponds to a single JMS connection.

For queue-based MDBs, the container creates and manages the JMS sessions used to receive messages and obtains an available bean instance from the pool for each invocation.

Topic-based MDBs may process messages serially, dispatch messages received through one JMS session to multiple pooled bean instances, or use multiple JMS sessions for concurrent consumption. This is automatically determined by the MDB container based on the message processing pattern specified by MDB application settings, the type of topic, the work-manager, and the max-beans-in-free-pool setting. See Configuring and Deploying MDBs Using JMS Topics. Also see Tuning Message-Driven Beans in Tuning Performance of Oracle WebLogic Server.

Limitations for Multi-threaded Topic MDBs

Examine the limitations for multi-threaded topic MDBs.

Topic MDB concurrency depends on the JMS provider, transaction settings, topic distribution mode, and concurrency settings. The default behavior for non-transactional topic MDBs is to multi-thread the message processing. There are some limitations when using:

  • Non-transactional topic MDBs that work with foreign (non-WebLogic) topics

  • Non-transactional topic MDBs in Compatibility mode that consume from a WebLogic JMS topic and process messages with a WebLogic JMS Unit-of-Order (UOO) value

For details, see the Caution in Controlling MDB Concurrency.