Message-driven beans - components
The WAS support for message-driven beans is based on JMS message listeners and the message listener service, and builds on the base support for JMS. The main components of WAS support for message-driven beans are shown in this figure and described after the figure:
This figure shows the main components of WebSphere support for message-driven beans, from a JMS provider through a connection to a destination, listener port, then a deployed message-driven bean that processes the message retrieved from the destination. Each listener port defines the association between a connection factory, destination, and a deployed message-driven bean. Listener ports are used to simplify the administration of the associations between these resources. The other main components are the message listener service, which comprises a listener for each listener port, all controlled by the same listener manager. The message listener service is an extension to the JMS functions of the JMS provider and provides a listener manager, which controls and monitors one or more JMS listeners.
Each listener monitors either a JMS queue destination (for point-to-point messaging) or a JMS topic destination (for publish/subscribe messaging).
A connection factory is used to create connections with the JMS provider for a specific JMS queue or topic destination. Each connection factory encapsulates the configuration parameters needed to create a connection to a JMS destination.
When a deployed message-driven bean is installed, it is associated with a listener port and the listener for a destination. When a message arrives on the destination, the listener passes the message to a new instance of a message-driven bean for processing.
When an application server is started, it initializes the listener manager based on the configuration data. The listener manager creates a dynamic session thread pool for use by listeners, creates and starts listeners, and during server termination controls the cleanup of listener message service resources. Each listener completes several steps for the JMS destination that it is to monitor, including:
- Creates a JMS server session pool, and allocates JMS server sessions and session threads for incoming messages.
- Creates a JMS connection consumers to listen for incoming messages.
- If the associated connection factory is XA enabled, then the listener manager starts a transaction and requests that it is committed (or rolled back) when the message-driven bean method has completed.
- Processes incoming messages by invoking the onMessage() method of the specified message-driven bean.