Java Reference
In-Depth Information
Inadditiontothismethod,thespecificationhasremovedtherestrictionsthatrequired
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 =
"destinationType",
propertyValue =
"javax.jms.Queue"),
@ActivationConfigProperty(propertyName =
"destinationLookup",
propertyValue =
"jms/messageQueue")
})
public class MessageBeanExample implements
MessageListener {
public MessageBeanExample() {
}
@Override
public void onMessage(Message message) {
try{
System.out.println("You have received
a new message of type : "+message.getJMSType());
Search WWH ::




Custom Search