Java Reference
In-Depth Information
the use of javax.ejb.Timer and javax.ejb.TimerHandlereferences only
inside a bean.
Harmonizing with JMS's novelties
A Message-Driven Bean ( MDB ) is a kind of a JMS Message listener allowing Java
EE applications to processmessages asynchronously. Todefine suchabean, simply
decorateasimplePOJOclasswith @MessageDriven annotationandmakeitimple-
ment the javax.jms.MessageListener interface. This interface makes available
to the MDB the onMessage method that will be called each time a new message is
posted in the queue associated with the bean. That's why you have to put inside this
method the business logic for the processing of incoming messages. The following
code gives an example of an MDB that notifies you when a new message arrives by
writing in the console:
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName =
propertyValue =
@ActivationConfigProperty(propertyName =
propertyValue =
public class MessageBeanExample implements
MessageListener {
public MessageBeanExample() {
public void onMessage(Message message) {
System.out.println("You have received
a new message of type : "+message.getJMSType());
Search WWH ::

Custom Search