Hi
I tried that, I don't get the error now in the server logs but the code
does not behave like I think it should.
I get this output from my code, with the MDB been executed after the
recv.receive(10000); timesout.
Sending hello
Sent hello
null
Got hello
Sent hello hello
Whys is the MDB blocking when I call this recv.receive(10000);??
Glen
-----Original Message-----
From: Ramesh.Parthasarathy_at_Sun.COM [mailto:Ramesh.Parthasarathy_at_Sun.COM]
Sent: 13 June 2008 16:24
To: users_at_glassfish.dev.java.net
Subject: Re: MDB Concurrency problem
Hi,
Could you use the LOCAL mode as a workaround for this issue Open admin
console:
http://localhost:4848, Select: Configuration -> Java Message
Service node in the tree on the left, Change the type from "EMBEDDED"
into "LOCAL", and restart glassfish.
Thanks
-Ramesh
Drinkwater, GJ (Glen) wrote:
> Hi
>
> I am trying to recreate the solution found on javaworld for one of my
> applications.
> http://www.javaworld.com/javaworld/jw-07-2003/jw-0718-mdb.html?page=1,
> basically using MDBs to concurrently do some work and then pass the
> results back to a SLSB that called the MDB.
>
> I cannot seem to get this to work, the MDB that is called never is
> executed until the
>
> MessageConsumer recv = session.createConsumer(replyQ);
>
> Message m = recv.receive(10000);
>
> Times out and then I get an error in glassfish v2 UR1
>
> DirectConsumer:Caught Exception delivering
> messagecom.sun.messaging.jmq.io.Packet cannot be cast to
> com.sun.messaging.jms.ra.DirectPacket
>
> It seems that the MDB is never executed and blocks with the call
> recv.receive(10000); and then is called after 10s. Is this the
> correct behaviour, I thought that MDB were executed in another thread?
> Why should it block?
>
> Here is my code below.
>
> Thanks Glen
>
>
> Method in SLSB:
>
> Connection connection = null;
> Session session = null;
> String text = "hello";
> try {
> System.out.println("Sending " + text);
> connection = searchDestFactory.createConnection();
> session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> TemporaryQueue replyQ = session.createTemporaryQueue();
>
> MessageProducer messageProducer =
> session.createProducer(searchDest);
> TextMessage tm = session.createTextMessage();
> tm.setText(text);
> tm.setJMSReplyTo(replyQ);
> messageProducer.send(tm);
> System.out.println("Sent " + text);
> MessageConsumer recv = session.createConsumer(replyQ);
>
> connection.start();
>
> Message m = recv.receive(10000);
> tm = (TextMessage) m;
> System.out.println(tm);
> } catch (JMSException ex) {
> System.out.println(ex);
> } finally {
> try {
> if (session != null) {
> session.close();
> }
> if (connection != null) {
> connection.close();
> }
> } catch (JMSException ex) {
> System.out.println(ex);
> }
> }
>
> -------------------------------------------------
>
> onMessagein MDB
>
> public void onMessage(Message message) {
> TextMessage tm = (TextMessage) message;
> Connection connection = null;
> Session session = null;
> try {
> try {
> System.out.println("Got " + tm.getText());
> connection = searchDestFactory.createConnection();
> session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> MessageProducer messageProducer =
> session.createProducer(tm.getJMSReplyTo());
> String result = "hello " + tm.getText();
> TextMessage newtm = session.createTextMessage();
> newtm.setText(result);
> newtm.setJMSCorrelationID(tm.getJMSMessageID());
> messageProducer.send(newtm);
> System.out.println("Sent " + result);
> } finally {
> if (session != null) {
> session.close();
> }
> if (connection != null) {
> connection.close();
> }
> }
> } catch (JMSException ex) {
> ex.printStackTrace();
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net