To create a message-driven bean, use the Enterprise Bean wizard to create a message-driven bean class source file, then implement the message listener method (onMessage()). The method is described below.
Using the Create EJB 3.0 Message-Driven Bean Wizard to create Message-driven Bean Classes
Select [EJB] > [Message-Driven Bean] from the [New] wizard, and the message-driven bean is created by the wizard. Refer below for the settings which are set by the wizard.
EJB project
Specify the EJB project that will generate the message-driven bean.
Source folder
Specify the folder where the message-driven bean source is stored.
Java package
Specify the name of the message-driven bean class package.
Class name
Specify the bean class name of the message-driven bean.
Destination name
Specify the JNDI name of the JMS resource.
JMS
Check if using JMS messages. If this is checked, set the "Destination type".
Destination type
If "JMS" is checked, select the destination type of the message-driven bean as "Queue" or "Topic".
Bean name
Specify the EJB name of the message-driven bean.
Transaction type
Select the transaction type as "Container" or "Bean".
Interfaces
Specify the interface to be used by the message-driven bean.
When the wizard is executed, the Java source for the message-driven bean class is generated.
Implementing the Message Listener Method (onMessage())
An empty onMessage() method is defined in the Java source of the message-driven bean class generated by the wizard. Implement the processing for the received message in this method.