How a message-driven bean connects in a cluster

When an enterprise bean (EJB) application is deployed to an application server cluster, the application can run on any of the servers in the cluster to provide high availability and scalability of the application. When the EJB application is a message-driven bean (MDB), it can run on any of the servers in the cluster (for high availability) and can be invoked concurrently in multiple application servers in the cluster (for scalability). This behavior depends on the location of the MDB with respect to any service integration bus members, and on the configuration of the MDB itself.

Note: For ease of management, connect the MDB directly to messaging engines in the bus member that owns the bus queue or subscription that the MDB is servicing, rather than connecting through intermediate messaging engines. For optimum messaging performance, deploy the MDB to the same application server or cluster as the bus member.

By default, when an MDB application is deployed to an application server cluster that is also a service integration bus cluster bus member, the MDB application connects to one or more messaging engines on servers within the cluster. The default connection behavior, and the extra connection control that you can apply to any JMS application including message-driven beans, are described in Connecting applications to a service integration bus. However, using these configuration options, the message-driven bean is only driven on those servers in the cluster that host a started messaging engine.

For MDB applications connecting to a cluster bus member, you can also enable either of the following additional configurations:
These configurations are described in more detail in the following sections:
The diagrams in these sections follow this key:

This figure is described in the surrounding text.

MDB connection behavior: Within a single cluster bus member

The message-driven bean is driven only on those servers in the cluster bus member that host a started messaging engine

This is the default option. If the message-driven bean is deployed to a cluster bus member then only the MDB endpoints in servers that have a messaging engine started locally are eligible to be driven by available messages.

In the following figure, a cluster bus member is shown that contains three servers. server1 and server2 each contain a messaging engine. The MDB endpoints running in each of these two servers connect to their respective local messaging engines. The third server is not hosting a started messaging engine, does not have an active MDB endpoint and is not eligible to consume messages.


This figure is described in the surrounding text.

This configuration also provides high availability of the MDB application, and the messages on the bus destination, if the messaging engines can fail over between servers in the cluster.

In the following figure, the same cluster bus member is shown as in the previous figure. The messaging engine in server1 has failed over to server2. Consequently, server2 now contains two messaging engines and the MDB endpoint running in server2 now connects to both of the local messaging engines. The third server is not hosting a started messaging engine, does not have an active MDB endpoint and is not eligible to consume messages.


This figure is described in the surrounding text.

MDB connection behavior: Between a cluster and a separate bus member

All servers in a cluster can receive messages from messaging engines in a cluster bus member

If you deploy the MDB application to a cluster that is not a bus member, the MDB attempts to connect to the bus from every application server in the cluster, following the connection rules described in Connecting applications to a service integration bus. This usually results in all of the MDB endpoints in the cluster being driven concurrently by messages from an active messaging engine in the bus member. This approach ensures that all the available resources of the cluster can be used to process messages sent to destinations in the cluster bus member.

In the following figure, a cluster contains three servers, each of which contains an MDB endpoint. There is also a cluster bus member that contains two servers, one of which has an active messaging engine. Each of the three MDB endpoints in the cluster connects to the active messaging engine in the cluster bus member.


This figure is described in the surrounding text.
Just one server in a cluster can receive messages from a messaging engine in a cluster bus member

To achieve sequential processing of the messages on the destination by a single server at a time, configure the system so that only a single MDB endpoint is driven by messages at any one time. In this pattern the other MDB endpoints and messaging engine are effectively in standby ready to take over processing of messages if server1 stops.

In the following figure a cluster contains three servers, each of which contains an MDB endpoint. There is also a cluster bus member that contains two servers, one of which has an active messaging engine. Only one of the three MDB endpoints in the cluster is connected to the active messaging engine running in the cluster bus member.


This figure is described in the surrounding text.

To choose this configuration you set the MDB endpoints in all the non-bus cluster servers as eligible to be driven by messages from a messaging engine in the cluster bus member, and set the receive exclusive option on the destination in the cluster bus member. When one of the MDB endpoints connects to the messaging engine, the engine stops all other available MDB endpoints from connecting and continues to process messages through the same MDB endpoint.

To achieve sequential processing of messages by an MDB further configuration might be required. For more information about ensuring sequential processing of the messages on a destination, see Message ordering.




Related concepts
Connecting applications to a service integration bus
Concept topic Concept topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 1:23:07 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=cjn_mdb_endpt_overview
File name: cjn_mdb_endpt_overview.html