Skip to Content
Java EE 8 Application Development
book

Java EE 8 Application Development

by David R. Heffelfinger
December 2017
Intermediate to advanced
372 pages
8h 46m
English
Packt Publishing
Content preview from Java EE 8 Application Development

Message-driven beans

The purpose of a message-driven bean is to consume messages from a Java Message Service (JMS) queue or a JMS topic, depending on the messaging domain used (refer to Chapter 8, Java Message Service). A message-driven bean must be decorated with the @MessageDriven annotation; the mappedName attribute of this annotation must contain the Java Naming and Directory Interface (JNDI) name of the JMS message queue or JMS message topic that the bean will be consuming messages from. The following example illustrates a simple message-driven bean:

package net.ensode.javaeebook; 
 
import javax.ejb.MessageDriven; 
import javax.jms.JMSException; 
import javax.jms.Message; 
import javax.jms.MessageListener; 
import javax.jms.TextMessage; 
 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java EE 8 Development with Eclipse

Java EE 8 Development with Eclipse

Ram Kulkarni
Beginning EJB in Java EE 8: Building Applications with Enterprise JavaBeans

Beginning EJB in Java EE 8: Building Applications with Enterprise JavaBeans

Jonathan Wetherbee, Massimo Nardone, Chirag Rathod, Raghu Kodali

Publisher Resources

ISBN: 9781788293679Supplemental Content