Pramati Technologies

Creating Message Driven Beans

Overview

A Message Driven Bean (MDB) is a stateless component invoked by the container as a result of the arrival of a JMS message. MDB does not have a Home or a component interface, and is an instance of a MDB class. MDB instance is created by the container to handle processing of messages, for which the bean is a consumer; the container controls its lifetime.

This document describes how to use Bean Wizard and create MDBs under a EJB 2.0 module.

Defining Message Driven Beans

Select Tools > Bean Wizard and define bean properties in the panel.

Table 1:
Attribute
Description
Module Name
Choose an EJB module from the dropdown. The bean when created is placed the chosen module
Bean Type
Define the type of bean to be created. Select bean type as Message Driven Bean from the dropdown
Transaction Type
Declare transaction as managed by the enterprise bean or container. Select transaction type as Container Managed or Bean Managed
Bean Class Name
Enter name of MDB class; if the bean is included under a package, the complete Java class name including the package name, should be entered
Adv
Click Adv to open the Advanced panel; enter custom interfaces implemented and custom classes extended by the bean class. Click OK to return to Bean Definition panel
EJB Name
Enter the logical name assigned to each bean in the ejb-jar here. This name is automatically added when the developer adds the bean class name. The name can be modified
Desc
Click Desc and enter the description of the EJB Name in the text box. This field is optional

Click Next to open the Define Message Driven Beans panel.

Defining Message Driven Beans

Provide the following details in Define Message Driven Beans panel:

Table 2:
Attribute
Description
Destination Type
Select destination type to which the MDB should be assigned. Destination type can be selected as Queue or Topic. Avoid associating more than one MDB with one JMS Queue
Destination Name
Enter name of the destination
Connection Factory
Select from the available Resource Manager Connection Factories in the container. Connection Factories are special entries in the enterprise bean environment and are used to create connections to the Resource Manager
Subscription Type
For destination type, Topic, this field is enabled. Select as durable or non-durable
Acknowledgement Mode
For transaction type, Bean Managed, this option is enabled. Container managed transactions handle message acknowledgement; these are used for a message received. Acknowledgement mode can be auto-acknowledge or dups-ok-acknowledge

Click Finish to create the MDB and the XML file under specified EJB 2.0 module.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX