1 Reply Latest reply on May 10, 2006 1:23 PM by rpiaggio

    Help with Timers

    rpiaggio

      Hi everyone,

      I am trying to use the Timer Service to do an automatic cancellation after a certain period has passed since the last modification to each record/entity in the database (unless the record is competed or cancelled) .

      For this purpose, I do the following:


      - I added a TimerHandle field/property to the entity.
      - In my DAO layer I have a method to create and to modify entity instances.

      - In the create method, I create a timer with the info paramter being a unique key for the entity. I also set the TimerHandle field of the entity to the handle of the new timer.
      - In the modify method, I want to reset the timer. To do this, I retrieve the TimerHandle from the entity, cancel it, and create a new one.

      - Of course, there's a @Timeout method that can instatiate the entity from the info of the timer.


      I have several issues/questions:

      1) The field created on the MySQL database to persist the TimerHandle is of type TINYBLOB. This causes the following runtime error:
      ERROR [JDBCExceptionReporter] Data truncation: Data too long for column 'timer' at row 1

      I can fix this by changing the column type to BLOB, but I think this is a bug. Should I JIRA it?

      2) The first time a timer is created, I get the following warning at runtime:
      WARN [TxConnectionManager] Prepare called on a local tx. Use of local transactions on a jta transaction with more than one branch may result in inconsistent data in some cases of failure.

      My educated guess is that JBoss is persisting the timer information in some internal database in order to be able to recover it in case of failure, and that this causes transactional problems.
      Is there any way to avoid this? Maybe JBoss can be configured to store timer information in my database?

      3) Is there a better way to reset the timer?

      4) I don't like at all having a BLOB field in my database for this purpose. I expect a lot of entries in this table. Is there an alternative? Can I reference a timer by some integer ID?


      Answers to any of these questions will be highly appreciated. Thank you in advance!


        • 1. Re: Help with Timers
          rpiaggio

          Nobody else is using TimerService??

          I have an additional problem: I tried relocating the logic in the Entity bean. But this does not work at all since resource injection is not working in entities. Is this the expected behavior?