Book Image

Java EE 5 Development with NetBeans 6

Book Image

Java EE 5 Development with NetBeans 6

Overview of this book

Table of Contents (17 chapters)
Java EE 5 Development with NetBeans 6
Credits
About the Author
About the Reviewers
Preface
Identifying Performance Issues with NetBeans Profiler

Processing JMS Messages with Message Driven Beans


In order to create a message driven bean, we need to right-click on our EJB project and select New | Message Driven Bean. In the resulting dialog window, we need to enter a name, package, and select a JMS destination for the message driven bean.

Once we have entered all the required information, our message driven bean is created in the specified package.

package com.ensode.mdb;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(mappedName = "jms/myQueue", activationConfig = {
@ActivationConfigProperty(
propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(
propertyName = "destinationType",
propertyValue = "javax.jms.Queue")
})
public class MessageReceiverBean implements MessageListener {
public MessageReceiverBean() {
}
public void onMessage(Message message) {
}
}

In the generated code, all we need...