Weblogic JMS & MDB Quickstart Guide?

Posted on 2005-03-23
Medium Priority
Last Modified: 2013-12-10

I want to use Message Driven Beans within Weblogic 7. In order to do this I want a (simple) working JMS Server with a Queue from which my MDB can consume. Having tried to work through the online help docs and experienced much pain (too much to configure, I just want a simple life!), I thought I would see if there is an easier way! So the following are what I would like:

JMS Server: BTNBJMSServer
Queue: CustomTaskQueue

MDB: MessageTFJ2EETranslatorEJB

That is it. I have created the Bean and deployed it to Weblogic successfully (well it doesn't give any errors). The problem is with the JMS side of things. Can someone give me a step by step guide to creating a simple server with a queue that I can use from within my MDB? Also how can I test my MDB? I don't see an option to put messages onto queues from the Weblogic console? Do I need to write a Java app to act as the producer and put messages onto the queue for the MDB?  

The following are the two descriptors and the MDB itself. Is there anything missing?:

ejb-jar.xml -


weblogic-ejb-jar.xml -


The MDB itself is as follows:

public class MessageTFJ2EETranslatorBean
        implements MessageDrivenBean, MessageListener
    private MessageDrivenContext ctx;

    public MessageTFJ2EETranslatorBean()

    public void onMessage(Message message)
        System.out.println("Message received: ");
            if (message instanceof TextMessage)
                System.out.println("TextMessage: " + ((TextMessage) message).getText());
            else if(message instanceof ObjectMessage)
                System.out.println("ObjectMessage: " + ((ObjectMessage)message).getObject());
            else if(message instanceof StreamMessage)
                System.out.println("StreamMessage: " + ((StreamMessage)message).readString());
            else if(message instanceof BytesMessage)
                System.out.println("BytesMessage: " + ((BytesMessage)message).readUTF());
            else if(message instanceof MapMessage)
                System.out.println("MapMessage: " + ((MapMessage)message).getString("msg"));
        catch (JMSException e)
            System.out.println("JMSException in onMessage(): " + e.getMessage());

    public void ejbRemove()
            throws EJBException

    public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext)
            throws EJBException
        this.ctx = messageDrivenContext;

    public void ejbCreate()
            throws CreateException
        System.out.println("Message Driven Bean Created");

Question by:scurtis_1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 11

Accepted Solution

sompol_kiatkamolchai earned 2000 total points
ID: 13619887
Hello scurtis,

You have 2 problem.

1.How to configure JMS server in WebLogic 7.
2.How to send message to queue.

1.Since I doesn't have version 7, I will guide you by follow admin ui in version 8. I think it's not different too much. You can follow the step below to configure it.

Create JMSServer
-Logon to administrator console "http://localhost:7001/console"
-Go to menu on the left pane "Services/JMS/Servers/"
-On the right pane click on the link "Configure a new JMSServer"
-Put the name(e.g. jmsserver1) of JMSServer and then click create button
-Target and deploy JMSServer on the server of WebLogic domain and then click apply button

Create queue destination
-Logon to administrator console "http://localhost:7001/console"
-Go to menu on the left pane "Services/JMS/Servers/jmsserver1/Destinations"
-On the right pane click on the link "Configure a new JMSQueue"
-Put the name of queue and JNDI name for MDB to consume.

2.Here is an example code to produce message to queue
InitialContext context = new InitialContext();
QueueConnectionFactory factory = (QueueConnectionFactory)context.lookup("javax.jms.QueueConnectionFactory");
QueueConnection con = factory.createQueueConnection();
QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue)context.lookup("CustomTaskQueue");
QueueSender sender = session.createSender(queue);
TextMessage msg = session.createTextMessage();
msg.setText("Hello World!");

Hope this help & Best luck to you.


Author Comment

ID: 13621712

Thanks for that. The JMS server and the message producer class now work! :-)

Unfortunately, my Message Driven Bean deploys but the onMessage method is never called? I know messages are available (ie making it onto the queue) as I can see them when I Monitor my CustomTaskQueue in the Weblogic Console?

Any ideas would be kindly received?


P.S. I have looked through the thread "What's wrong with my FIRST MessageDrivenBean :(" and none of the suggestions seem to help?

Author Comment

ID: 13622464
Ok, worked it out. In my Producer I was using the following line:

session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);

By setting the boolean (transacted) parameter to false it is now picking up the messages from the queue. The problem is that it doesn't do a destructive read, only a 'browse' and it only ever picks up any new incoming messages, not those that were already on the queue when the bean was created?

Can anyone tell me how to make my bean consume the messages from the queue and how to make it pick up any waiting messages when it first starts up?


Author Comment

ID: 13623101
Ok, I was being dumb! I was expecting something like 'Queue Depth' which would show the number of messages still waiting, but in Weblogic JMS it appears to be called 'Messages High'?

Oh well, that just about wraps this thread up. Thanks again for your help SOMPOL and enjoy the points! :-)


Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question