Pramati Technologies

Creating Message Driven Beans

A message-driven bean is a stateless component that is invoked by the container as a result of the arrival of a JMS message. A message-driven bean has neither a home nor a component interface, and is an instance of a message-driven-bean class.

A message-driven bean instance is created by the container to handle the processing of the messages, for which the message-driven bean is the consumer. The container controls its lifetime.

The following section describes how to use the Bean Wizard and create a message driven bean. Message driven beans can be created only under an EJB 2.0 module.

Defining Beans

The first panel that comes up requires the bean to be defined. Fill in the following information here:

Module Name All the EJB Modules existing in the active Desk are displayed here. Choose one from the list available in the combo-box. The message driven bean that is created is placed under the module chosen here.

Bean Type This field defines the type of bean to be created. Select the bean type as Message Driven Bean from the list in the combo box.

Transaction Type This field allows the user to declares whether the transaction is managed by the enterprise bean or the container. Select the transaction type as Container Managed or Bean Managed.

Bean Class Name The name of the message driven bean class is entered in this field. If the bean is included under a package, the complete Java class name, including the package name, must be entered.

EJB Name The logical name assigned to each bean in the ejb-jar is entered here. This name is automatically added when the developer adds the bean class name. The developer, if required can modify the name.

Click Next after completing all the required fields. This brings up the panel called Define Message Driven Beans.

Defining Message Driven Beans

The MDB Details panel helps the user declare details like destination, connection factory, and subscription type to the message driven bean.

Destination Type Select the destination type to which the message driven bean should be assigned. The destination type can be either selected as Queue or Topic. Associating more than one message-driven-bean with one JMS Queue should be avoided.

Destination Name Enter the name of the destination name after selecting the type of destination.

Connection Factory Select from the available resource manager connection factories in the container. Connection factories are special entries in the enterprise bean's environment and are used to create connections to the resource manager.

Subscription Type Selecting the destination type as Topic, enables the Subscription Type field. The subscription type can be either durable or non-durable.

Acknowledgement Mode This field is enabled only when the transaction type is selected as Bean Managed in the previous panel. Container managed transactions handle the message acknowledgement automatically. Acknowledgments are used to accept when a message is received. The acknowledgement can be either auto-acknowledge or dups-ok-acknowledge.

After filling all the required information, click Finish. This creates the message driven bean and the xml file under the specified EJB 2.0 module.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX