O'Reilly logo

J2EE™ Applications and BEA™ WebLogic Server™ by Sandra L. Emerson, Rob Woollen, Michael Girdley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Message-Driven EJB Example

Let's now develop a simple message-driven EJB to receive text messages from a JMS queue and print the messages to the server's stderr.

The MessageDrivenBean class includes the four required methods. The onMessage method receives the JMS message and prints the associated text. For this simple example, any error is simply printed to the server's stderr.

MessagePrinterBean Class

 package com.learnweblogic.examples.ch10.textmessage; import javax.ejb.MessageDrivenBean; import javax.ejb.MessageDrivenContext; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; public class MessagePrinterBean implements MessageDrivenBean, MessageListener { private MessageDrivenContext ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required