4 Replies Latest reply on Dec 17, 2009 8:46 AM by jaikiran pai

    MDB and @Timeout

    Frans van Niekerk Newbie

      I am trying to get the @Timeout annotation to work with a MDB implementation.

       

      The MDB extends a super class that has a final method that creates the timer and calls an EJB. The super class also has the annotated timeout method.

       

      To test the implementation I called a method on an EJB that sleeps for 4 seconds. The timeout is set to 2 seconds. The timeout method is not called when it should. The MDB just completes as if no timeout was set. If I run getTimeRemaining on the Timer it returns a negative value.

       

      Am I correct in saying that @Timeout can be used with MDBs, ff so, what am I doing wrong?

       

      A simplified version of the implementation:

       

      public abstract class AbstractMDB{

       

        private ASessionBean sb;

       

        @Resource

        private TimerService ts;

       

        public final onMessage(Message m){

       

          ts.createTimer(2000, null);

          sb.execute(m);

          ts.cancel();

        }

       

        @Timeout

        public void timeout(Timer t){

       

          sb.timeout();

        }

      }

       

      @MessageDriven(...)

      public class ActualMdb extends AbstractMDB{

       

          @Override
          @EJB(mappedName = "...")
          public void setSessionBean(EjbInterface ejb) {

       

              sb = ejb;
          }

      }