3 Replies Latest reply on Nov 10, 2004 7:40 PM by Claude Hussenet

    Asynchronous Aspect for Tomcat

    petercahanlon Newbie

      Running the Asynchronous Aspect or any others aspects outside of JBOSS server is quite straitghforward.

      They are differents options of deployment based on your requirements (See Reference doc Chap 10)

      I personally tested two configurations with Tomcat 5.0


      JDK 1.4 using the precompiler.
      ------------------------------
      Create a war file as follow :
      WEB-INF/lib/concurrent.jar
      WEB-INF/lib/jboss-aop.jar
      WEB-INF/lib/jboss-aspect-library.jar
      WEB-INF/lib/jboss-common.jar
      WEB-INF/lib/javassist.jar
      WEB-INF/lib/trove.jar

      WEB-INF/classes/META-INF/jboss-aop.xml
      WEB-INF/classes/...

      JDK 1.5 (Loadtime)
      -------
      Modify the classpath as follow ( Use the Configure Tomcat dialogbox)
      -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader

      Create a war file as follow :
      WEB-INF/lib/concurrent.jar
      WEB-INF/lib/jboss-aop-jdk50.jar
      WEB-INF/lib/jboss-aspect-library-jdk50.jar
      WEB-INF/lib/jboss-common.jar
      WEB-INF/lib/javassist.jar
      WEB-INF/lib/trove.jar

      WEB-INF/classes/META-INF/jboss-aop.xml
      WEB-INF/classes/...


      An alternative for both options (JDK 1.4/JDK 1.5) is to install
      the libraries under CATALINA_HOME/common/endorsed and the jboss-aop.xml
      under CATALINA_HOME/common/classes so u don't need to package them with the war file.


      2/The Asynchronous Aspect does catch all exceptions.
      So in order to test ,if the asynchronous method raises an exception do the following :

      For example if the method execute was annotated with the asynchronous annotation.
      POJO p = new POJO();
      long value=p.execute();
      AsynchronousFacade facade = (AsynchronousFacade)p;

      // Test if the method raised an exception and get the Exception object.
      if (p.getResponseCode()==AsynchronousConstants.EXCEPTIONCAUGHT)
      {
      ((Exception)p.getResponseObject()).printStackTrace();
      }

      The following constants are also available :

      AsynchronousConstants.OK (Asynchronous method completed succesfully)
      AsynchronousConstants.TIMEOUT (Asynchronons method completed but did timeout)
      AsynchronousConstants.NOVALUE (Asynchronous method still running)

      I hope it helps .

      Rgds-Claude

        • 1. Re: Asynchronous Aspect for Tomcat
          Claude Hussenet Newbie

          Running the Asynchronous Aspect or any others aspects outside of JBOSS server is quite straitghforward.

          They are differents options of deployment based on your requirements (See Reference doc Chap 10)

          I personally tested two configurations with Tomcat 5.0


          JDK 1.4 using the precompiler.
          ------------------------------
          Create a war file as follow :
          WEB-INF/lib/concurrent.jar
          WEB-INF/lib/jboss-aop.jar
          WEB-INF/lib/jboss-aspect-library.jar
          WEB-INF/lib/jboss-common.jar
          WEB-INF/lib/javassist.jar
          WEB-INF/lib/trove.jar

          WEB-INF/classes/META-INF/jboss-aop.xml
          WEB-INF/classes/...

          JDK 1.5 (Loadtime)
          -------
          Modify the classpath as follow ( Use the Configure Tomcat dialogbox)
          -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader

          Create a war file as follow :
          WEB-INF/lib/concurrent.jar
          WEB-INF/lib/jboss-aop-jdk50.jar
          WEB-INF/lib/jboss-aspect-library-jdk50.jar
          WEB-INF/lib/jboss-common.jar
          WEB-INF/lib/javassist.jar
          WEB-INF/lib/trove.jar

          WEB-INF/classes/META-INF/jboss-aop.xml
          WEB-INF/classes/...


          An alternative for both options (JDK 1.4/JDK 1.5) is to install
          the libraries under CATALINA_HOME/common/endorsed and the jboss-aop.xml
          under CATALINA_HOME/common/classes so u don't need to package them with the war file.


          2/The Asynchronous Aspect does catch all exceptions.
          So in order to test ,if the asynchronous method raises an exception do the following :

          For example if the method execute was annotated with the asynchronous annotation.
          POJO p = new POJO();
          long value=p.execute();
          AsynchronousFacade facade = (AsynchronousFacade)p;

          // Test if the method raised an exception and get the Exception object.
          if (p.getResponseCode()==AsynchronousConstants.EXCEPTIONCAUGHT)
          {
          ((Exception)p.getResponseObject()).printStackTrace();
          }

          The following constants are also available :

          AsynchronousConstants.OK (Asynchronous method completed succesfully)
          AsynchronousConstants.TIMEOUT (Asynchronons method completed but did timeout)
          AsynchronousConstants.NOVALUE (Asynchronous method still running)

          I hope it helps .

          Rgds-Claude

          • 2. Re: Asynchronous Aspect for Tomcat
            ravi76 Newbie

            Can we specify timeout for Asynchronous Aspect ? How to do that in weblogic ?

            Regards,
            Ravi

            • 3. Re: Asynchronous Aspect for Tomcat
              Claude Hussenet Newbie

              1/Yes.The asynchronous aspects does support timeout value.

              With jdk1.4,u have two options to specify the value:
              * In your code,when u flag the method as an asynchronous method
              /** @@org.jboss.aspects.asynchronous.aspects.jboss.Asynchronous (timeout=5000)*/
              public long myProcess(){...}
              * At run-time ,before calling the method flagged as asynchronous
              POJO p = new PO JO();
              ((AsynchronousFacade)pojo).setTimeout(timeoutValueInMilliSec);
              long result = myProcess();

              With JDK 1.5,the timeout value is mandatory when u specify the annotation.However,u can still overwrite the value specified in your annotation in your code as described below.

              2/
              The first configuration proposed in the previous post should work in any WEB container .
              I tested with WL 8.1 and I didn't encounter any issue.

              Let me know..

              Claude