users@glassfish.java.net

Re: Why Does The Simple Java EE 5.0 MDB Example Not Work?

From: <glassfish_at_javadesktop.org>
Date: Sun, 25 Nov 2007 11:50:59 PST

Hi

This is really ridiculously easy to explain. JMS/MDB does not seem to working for GF2 b58 fcs. Why?

This is the client side code:

[code]
package ejb30;

import javax.annotation.Resource;
import javax.jms.*;

public class MDBAppClient {

    @Resource(mappedName="MDBQueueConnectionFactory")
    private static QueueConnectionFactory queueCF;

    @Resource(mappedName="MDBQueue")
    private static Queue mdbQueue;

    public static void main(String args[]) {

        try {
            QueueConnection queueCon = queueCF.createQueueConnection();
            QueueSession queueSession = queueCon.createQueueSession
                (false, Session.AUTO_ACKNOWLEDGE);
            QueueSender queueSender = queueSession.createSender(null);
            TextMessage msg = queueSession.createTextMessage("hello");
            queueSender.send(mdbQueue, msg);
            System.out.println("Sent message to MDB");
            queueCon.close();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}
[/code]

And this the server side code:

[code]
package ejb30;

import javax.ejb.MessageDriven;
import javax.jms.MessageListener;
import javax.jms.Message;

@MessageDriven(mappedName="MDBQueue")
public class MDB implements MessageListener {

    public void onMessage(Message msg) {
        System.out.println("Got message!");
    }

}
[/code]

I have worked with WebLogic and WebSphere in the past, but this one has flummoxed me this weekend. I still do not know why this simple example does work. Is there a standard port? Or a JNDI property setting that needs setting? Or it part of the app server configuration?
 
Also there is no output in the server.log any more? Why has this stopped logging errors?

What is the Glassfish Server that everyone else recommends?
[Message sent by forum member 'peter_pilgrim' (peter_pilgrim)]

http://forums.java.net/jive/thread.jspa?messageID=247055