0 Replies Latest reply on Aug 1, 2002 7:38 AM by rickertj

    Again Session.recover() or Session rollback() not working !

    rickertj

      I still have this problem (former Thread about CLIENT_ACKNOWLEDGE and local Transactions).
      I was told, that it was fixed in latest CVS release, so I checked it out and built it. Now I have a running Jboss3.1.0alpha, but my problems still exist.

      An example:
      I have some code that produces some msg.:

      package expjndi;

      import javax.jms.*;
      import javax.naming.*;
      import java.io.*;
      import java.util.*;


      public class snd {

      private static InitialContext ctx;
      private static QueueConnectionFactory conFactory;
      private static QueueConnection con;
      private static QueueSession session;
      private static Queue queue;
      private static QueueSender snd;
      private static TextMessage answer;


      public snd () {
      }
      public static void main(String[] args) {
      try {

      Hashtable env = new Hashtable();

      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://Leon");

      ctx = new InitialContext(env);

      conFactory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
      con = conFactory.createQueueConnection();
      con.start();
      queue = (Queue) ctx.lookup("queue/testQueue");
      session = con.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);

      snd = session.createSender(queue);
      answer = session.createTextMessage("Aha 1.");
      snd.send(answer);

      answer = session.createTextMessage("Aha 2.");
      snd.send(answer);

      answer = session.createTextMessage("Aha 3.");
      snd.send(answer);

      session.close();
      con.close();
      }
      catch (Exception e) {
      e.printStackTrace();
      }

      }
      }

      Fine, compiles and does its job.

      Next I launch some code to receive ONE msg and then quit
      without closing session and connection and (very important !) without acknowledging the msg.

      package expjndi;

      import javax.jms.*;
      import javax.naming.*;
      import java.io.*;
      import java.util.*;


      public class rcv {

      private static InitialContext ctx;
      private static QueueConnectionFactory conFactory;
      private static QueueConnection con;
      private static QueueSession session1;
      private static Queue queue;
      private static QueueReceiver rcv;
      private static TextMessage answer;



      public rcv () {
      }
      public static void main(String[] args) {

      try {
      Hashtable env = new Hashtable();

      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://Leon");

      ctx = new InitialContext(env);

      conFactory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
      con = conFactory.createQueueConnection();
      con.start();
      queue = (Queue) ctx.lookup("queue/testQueue");

      session1 = con.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
      session1.recover();

      rcv = session1.createReceiver(queue);
      answer = (TextMessage) rcv.receive();
      System.out.println(answer.getText());

      }
      catch (Exception e) {
      e.printStackTrace();
      }

      }
      }

      So I would expect, that everytime I run rcv, it should receive the same msg "Aha 1", because it is never acknowledged and so has to be redelivered all the time.
      This does not happen.
      The same thing is when I change the code to transacted mode and do not commit the msg and do a rollback().
      I only receive the msg again, when I restart the server.
      I also checked out Jboss-MQ, but I cannot build it, because of an error.

      error (
      E:\jboss-src\jboss-mq\build>build.bat

      Calling ..\tools\bin\ant.bat
      Buildfile: build.xml
      Trying to override old definition of task property

      _buildmagic:init:

      _buildmagic:init:local-properties:
      [copy] Copying 1 file to E:\jboss-src\jboss-mq\build

      _buildmagic:init:buildlog:

      configure:
      [echo] groups: default
      [echo] modules: jmx,common,system,j2ee,naming,management,server,security,po
      ol,connector,messaging

      init:

      _buildmagic:modules:most:
      [execmodules]
      [execmodules] ==============================================================
      ========
      [execmodules] == Executing 'most' in module 'jmx'...
      [execmodules] ==

      BUILD FAILED
      jar:file:/E:/jboss-src/jboss-mq/tools/lib/buildmagic-tasks.jar!/org/jboss/tools/
      buildmagic/common.xml:242: You must specify value, location or refid with the name attribute

      Total time: 1 second

      ) // end error

      Sorry for the long post, but meanwhile I really need help,
      spent already a lot of time on this.
      Regards,
      jwr