Implementing a Message-Driven Bean in Orion.

(Tested with orion 1.5.4)

1.) ==========================  The MDB code - LogBean

package mycode.ejb.mdb;

import javax.ejb.*;
import javax.jms.*;

public class LogBean implements MessageDrivenBean, MessageListener {

 protected MessageDrivenContext ctx;

 public void setMessageDrivenContext(MessageDrivenContext ctx) {
  this.ctx = ctx;

 public void ejbCreate() {

 public void onMessage(Message msg) {

  TextMessage tm = (TextMessage) msg;

  try {
   String text = tm.getText();
   System.out.println("Received new message : " + text);
  catch(JMSException e) {

 public void ejbRemove() {

2.) ========================== The deployment descriptor (ejb.jar)

<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.2//EN" 

        <display-name>Test Message Bean</display-name>
        <description>A test of message beans</description>

                 <!-- The name for the bean - used in binding with jms -->

                 <!-- The fully qualified package name of the bean class -->

                 <!-- The type of transaction supported (see Chapter 10) -->

                 <!-- Whether I'm listening to a topic or a queue -->



3.) ==========================  Activate (uncomment) jms in server.xml

4.) ==========================  Update jms.xml to include the queue

        <queue name="Log" location="jms/theLog">
                <description>Test queue for MDB LogBean</description>

5.) ==========================  Update web.xml to include the resource references to 
jms factory and queue



6.) ==========================  Send a message to the jms queue from application code 
(jsp in this case)

<%@ page import="javax.naming.*" %>
<%@ page import="javax.jms.*" %>


                Context context = new InitialContext();
          QueueConnectionFactory factory = 

                QueueConnection connection = factory.createQueueConnection();
                Queue queue = (Queue)context.lookup("java:comp/env/jms/theLog");

                QueueSession sess = connection.createQueueSession(false, 

                QueueSender sender = sess.createSender(queue);

                int delivery_mode = DeliveryMode.PERSISTENT;
                TextMessage message = sess.createTextMessage("well hello there...");
                sender.send(message, delivery_mode, 1, 0);


        } catch(JMSException e) {
                System.err.println("JMS Communication error: " + e.getMessage());
        } catch(NamingException e) {
                System.err.println("Naming Error looking up objects: " + 


<title>Asp Services - Test</title>
<link rel ="stylesheet" type="text/css" href="./stylesheet.css" title="Style">


7.) ==========================  Done. 

Note: LogBean example was taken from "Mastering Enterprise Beans II (draft)" from


-----Original Message-----
From: Michael Maurer [mailto:[EMAIL PROTECTED]]
Sent: 29 April 2002 01:20 PM
To: Orion-Interest
Subject: Message Driven Beans 

I am trying to deploy a message driven bean on the Oracle9iAS

Are there some good examples where all necessary settings are described?
(Starting from jms.xml to orion-ejb-jar.xml!)

Or can anybody help me out with some important hints ?

Regards Michael

Reply via email to