Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1681

ejbTimeout() shouldn't log a warning when run outside a CM transaction

    XMLWordPrintable

Details

    Description

      We are having problems with the JBoss TimerService. We upgraded to JBoss 4.0.1sp1 to see if the Timer fixes there solves anything

      Our issues are:
      1 ? Timers are removed when doing a ?nice? shutdown.
      We fixed this by implementing our own ScapEJBTimerServiceImpl, see code below. This seems to work fine.

      Is there a better/more correct way? (I would rather not modify JBoss functionality?.)

      2 ? Timer.cancel in Transaction
      CartBean implements TimedObject, all methods have TransactionType=Required, using ContainerManaged Persistence and Transactions
      addItem restarts idleTimer (Timer.cancel, createNewTimer)
      ejbTimeout is then only called if customer is idle and marks the cart as timed-out. (Note: No rollback is performed)

      The problem is that Timer.cancel put?s the Timer in state CANCEL_IN_TX. The Timer is then never deleted (killTimer is not called, the TIMERS table entry is not removed, and the TimerTask is taking CPU time.) On server reboot, all the cancelled timers are activated, since TimerState is not entered into the TIMERS table.

      One solution is to modify the TimerImpl to call killTimer in TimerTask.run if Timer is cancelled ? this is made cumbersome because all fields in TimerImpl are private, not protected

      Is there another way? (I suspect a better use of Transactions ? my understanding of how they are meant to be used is limited.)

      3 ? Timer without Transaction
      We also have a Status poll timer. After we set TransactionType to Never, it works as we want, and is removed from the database when cancelled.
      The problem is that a Timer without a Transaction gives a very noisy log ? because of the log.warn statement in TimerTaskImpl.run:
      WARN [TimerImpl] Timer was not registered with Tx, reseting state: [id=5target=[target=jboss.j2ee:jndiName=ejb/ScapServerAdminLocal,service=EJB],remaining=9026,periode=10000,in_timeout]

      Again I could simply remove the statement from a derived class, but this is cumbersome because the class is private, not protected

      4 ? Duplicate primary key
      Because the TargetID is only 80 bytes, it is truncated ? easily fixed by modifying ScapEJBTimerServiceImpl, but maybe you have a better solution?

      5 ? Invalid timers not removed
      If I redeploy/undeploy my beans, the Timers are still there, attempting to call invalid references. (May be related to 1 above I guess)
      Would it not be appropriate to kill the Timer if an exception is thrown?

      I hope you can shed some light on this ? we have relied on ejbTimeout several places in the business logic, and do not want to redesign if we can avoid it.

      ScapEJBTimerServiceImpl :
      public class ScapEJBTimerServiceImpl extends EJBTimerServiceImpl
      {
      private Logger log = Logger.getLogger(ScapEJBTimerServiceImpl.class);

      /* (non-Javadoc)

      • @see org.jboss.ejb.txtimer.EJBTimerServiceImpl#removeTimerService(javax.management.ObjectName, java.lang.Object)
        */
        public void removeTimerService(ObjectName containerId, Object instancePk) { if (instancePk!=null) super.removeTimerService(containerId, instancePk); else log.info("Request to remove all Timers ignored."); }

        }

      Attachments

        Activity

          People

            dandread1@redhat.com Dimitrios Andreadis
            hanseno2 Øystein Hansen (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: