ejb@glassfish.java.net

Re: Message Driven Bean

From: Dies Koper <dies_at_jp.fujitsu.com>
Date: Wed, 14 Nov 2007 09:07:45 +0900

It looks like the client sent the message successfully to the
destination queue, but the MDB is not receiving it.

There are some commands in imq\bin that you can use to check whether
there are any messages in the queue.
Hopefully someone else can provide you with some hints on how to go from
there.

I once had the same problem when I used a cluster with two instances to
deploy my application into. It had worked fine when I used the
standalone DAS. I gave up at the time, but if you figure out how to
investigate this further, I'd love to hear about it too.

Regards,
Dies


Bart de Jonge wrote:
> Hi,
>
> I'm new to java and beans.
> I'm using the Eclipse IDE, version Europa.
> I've installed Sun Java App Server 9.1.
> I've installed the Eclipse plugin for Glassfish V2.
>
> First I took on the ejb session bean example.
> I managed to make ik work using an AppClient and Java Web Start.
>
> Now I'm trying to finish the message driven bean using the Glassfish example
> as explained on https://glassfish.dev.java.net/javaee5/ejb/examples/MDB.html
> I also did some succesfull configuration of JMS stuff on the server.
>
> Deploying of the MDBBean project succeeds
> Also the deploying of the EAR (containing the AppClient project and the
> MDBBean project) succeeds.
>
> But when I run the AppClient with Java Web Start nothing happens.
> That is: I cannot find the the system.out.println on the client side
> anywhere nor can I find the logger.info strings on the server side (in
> server.log).
>
> Have you got any hints where to go from here?
>
> Thanx in advance for the response.
>
> FYI;
> The client sidecode looks like this (plse forgive me the unindenting):
>
> import javax.annotation.Resource;
>
> import javax.jms.JMSException;
>
> import javax.jms.Queue;
>
> import javax.jms.QueueConnection;
>
> import javax.jms.QueueConnectionFactory;
>
> import javax.jms.QueueSender;
>
> import javax.jms.QueueSession;
>
> import javax.jms.Session;
>
> import javax.jms.TextMessage;
>
> import com.ui.SimpleUI;
>
> public class Main {
>
> @Resource(mappedName="jms/MDBQueueConnectionFactory")
>
> private static QueueConnectionFactory queueCF;
>
> @Resource(mappedName="jms/MDBQueue")
>
> private static Queue mdbQueue;
>
> /* (non-Java-doc)
>
> * @see java.lang.Object#Object()
>
> */
>
> public Main() {
>
> super();
>
> }
>
> public static void main(String[] args) {
>
> QueueConnection queueCon = null;
>
> try {
>
> queueCon = queueCF.createQueueConnection();
>
> QueueSession queueSession = queueCon.createQueueSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> QueueSender queueSender = queueSession.createSender(null);
>
> TextMessage msg = queueSession.createTextMessage("hallo vanuit de
> client");
>
> queueSender.send(mdbQueue, msg);
>
> } catch (JMSException e) {
>
> System.out.println("sendText failed " + e.getLocalizedMessage());
>
> e.printStackTrace();
>
> } catch (Exception e) {
>
> System.out.println("exception.e " + e.getLocalizedMessage());
>
> e.printStackTrace();
>
> }
>
> finally {
>
> try {
>
> if (queueCon != null) {
>
> queueCon.close();
>
> }
>
> } catch (JMSException e) {
>
> }
>
> }
>
> }
>
>
> }
>
>
>
>
> The bean class is as follows:
> package com.mdbs;
>
> import java.util.logging.Logger;
>
> import javax.ejb.MessageDriven;
>
> import javax.jms.JMSException;
>
> import javax.jms.Message;
>
> import javax.jms.MessageListener;
>
> import javax.jms.TextMessage;
>
>
>
> @MessageDriven(mappedName="jms/MDBQueue")
>
> public class TestMDB implements MessageListener {
>
> static final Logger logger = Logger.getLogger("TestMDB");
>
> public TestMDB() {
>
> super();
>
> logger.info("I'm the constructor");
>
> }
>
> public void onMessage(Message myMsg) {
>
> TextMessage txtMsg = (TextMessage)myMsg;
>
> try {
>
> logger.info("I'm the message driven bean " +
> txtMsg.getText());
>
> } catch (JMSException e1) {
>
> logger.warning("jsm exception " + e1.getLocalizedMessage());
>
> e1.printStackTrace();
>
> }
>
> }
>
> }
>
>
>
>
> Met vriendelijke groet, kind regards,
>
>
>
> Bart de Jonge
>
> TeamSoft Groep
>
> T: +31 - (0)78-6999333
>
> M: +31 - 6-13450680
>
> E: bart.de.jonge_at_teamsoft.nl
>
>
>
>
>

-- 
Dies KOPER <dies_at_jp.fujitsu.com>
Fujitsu Ltd - Application Management Middleware Div. (APMM2)
Tech Bldg. B-11F, Shin-Yokohama, Japan
Tel. +81(45)-474-1927  (internal 7124-3023)