4 Replies Latest reply on Aug 16, 2007 4:01 AM by vadger

    jBoss Seam 2.0 Beta 1 Asynchronicity issues

    vadger

      Hello,

      I'm trying to launch asynchronicity and I've faced with a number of problems.

      What I've done:

      @Stateless
      @Name("prevedMedved")
      public class PrevedBean implements IPreved {
      
       @Logger
       private Log log;
      
       @In(create = true)
       TaskHandler taskHandler;
      
       @Observer("org.jboss.seam.postInitialization")
       public void sayPreved() {
       log.info("PREVEEED MEDVEEEEEED!!!!! ##################");
       log.info("IBVOKING TASKING4 after 1 minute");
       Calendar cal = Calendar.getInstance();
       cal.setTime(new Date());
       cal.add(Calendar.MINUTE, 1);
       taskHandler.sayGreeting("PREVED, KROSAV4EGI", cal.getTime(), 1000L);
       }
      }


      @Local
      public interface TaskHandler {
       @Asynchronous
       void sayGreeting(String greeting, @Expiration Date date, @IntervalDuration Long interval);
      }
      


      @AutoCreate
      @Name("taskHandler")
      public class TaskHandlerBean implements TaskHandler {
      
       @Logger
       Log log;
      
       @Override
       public void sayGreeting(String greeting, Date date, Long interval) {
       log.info("greeting: #0 at #1", greeting, new Date());
       }
      
      }


      I just tried to make tasking by example given in documentation.
      When the method sayPreved is being invoked after deployment the method sayGreeting is invoked immediatly - not after 1 minute as I expected. In addition I don't see any recurrent invocation. What am I doing wrong?

      Another issue. I tried to add <async:timer-service-dispatcher/> to the components.xml as it is written in documentation to use EJB3 Timer. In application deployment I got initilization exception:
      .....
      Caused by: org.dom4j.DocumentException: Error on line 44 of document : The prefix "async" for element "async:timer-service-dispatcher" is not bound. Nested exception: The prefix "async" for element "async:timer-service-dispatcher" is not bound.
      at org.dom4j.io.SAXReader.read(SAXReader.java:482)
      at org.dom4j.io.SAXReader.read(SAXReader.java:343)
      at org.jboss.seam.util.XML.getRootElement(XML.java:16)
      at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:130)

      As I understand, the schema location for async is not specified. Is it bug?

      Thanks



        • 1. Re: jBoss Seam 2.0 Beta 1 Asynchronicity issues
          gbc1

          Manual does not mention...

          Change your components.xml like this, adding a namespace for async at components tag:

          
          <?xml version="1.0" encoding="UTF-8"?>
          <components xmlns="http://jboss.com/products/seam/components"
           xmlns:core="http://jboss.com/products/seam/core"
           xmlns:async="http://jboss.com/products/seam/async"
           xmlns:persistence="http://jboss.com/products/seam/persistence"
           xmlns:drools="http://jboss.com/products/seam/drools"
           xmlns:security="http://jboss.com/products/seam/security"
           xmlns:mail="http://jboss.com/products/seam/mail"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation=
           "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
           http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
           http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
           http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
           http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
           http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
          
           <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
          
           <core:manager concurrent-request-timeout="500"
           conversation-timeout="120000"
           conversation-id-parameter="cid"/>
          
           <async:timer-service-dispatcher/>
          
          ...
          
          </components>
          
          


          JBoss starts up as configured:

          
          22:40:00,906 INFO [Component] Component: org.jboss.seam.async.dispatcher, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: org.jboss.seam.async.TimerServiceDispatcher, JNDI: Server/TimerServiceDispatcher/local
          
          


          Much fun!, Greetz GHad

          • 2. Re: jBoss Seam 2.0 Beta 1 Asynchronicity issues
            vadger

            Thanks, it helped - no xml validation errors anymore. But still timer does not work. Can anybody tell me what I'm doing wrong?

            Thanks

            • 3. Re: jBoss Seam 2.0 Beta 1 Asynchronicity issues
              vadger

              I tried to use pure EJB3 Timer With annotations @Timer by tutorial

              http://java-x.blogspot.com/2007/01/ejb-3-timer-service.html

              and it works, but a little bit strange :)

              • 4. Re: jBoss Seam 2.0 Beta 1 Asynchronicity issues
                vadger

                I've found how to put it to work.
                I annotated Task Handler implementation - not only interface as it is written in documentation, also I added just in case @Stateless annotation for my bean :) one of operations gave me a positive result :)

                @AutoCreate
                @Name("taskHandler")
                @Stateless
                public class TaskHandlerBean implements TaskHandler {

                @Logger
                Log log;

                @Override
                @Asynchronous
                public void sayGreeting(String greeting, @Expiration Date date, @IntervalDuration Long interval) {
                log.info("greeting: #0 at #1", greeting, new Date());
                }

                }

                Thanks for help.