You can use Java™ EE
annotations to create a message-driven bean and add it to your project.
Before you begin
You must have a Java project,
an EJB project, or a web project created in your workspace.
About this task
The main difference between a message-driven bean and
a session bean is that a message-driven bean has no local or remote
interface. Instead, it has only a bean class.
Procedure
- In the Java EE perspective,
click .
- In the Source folder field, select
the source folder for the new bean.
- In the Default package field, type
the package name for the new bean, and click Finish.
- In the Java class
editor, underneath the package declaration, type @MessageDriven.
You can see an error / quick fix icon
next to the @MessageDriven line. Tip: You can simply type
@Mess and
then press CTRL+Spacebar to see the options in content assistance:
- You can see an error / quick fix icon
next to the @MessageDriven line.
Right click the quick fix icon and select Quick Fix:
- Select @MessageDriven(EJB) and the
tools automatically add the dependency import javax.ejb.MessageDriven;.
- In the Enterprise Explorer view, expand your , and your new message-driven bean Java class is listed under its package name.
- You can use the @MessageDriven annotation
to specify properties for the bean, including
- Destination type
- A durable subscription
- A message selector
- An acknowledgment mode