3 Replies Latest reply on Jan 28, 2010 11:38 AM by fwelland

    Timer Persistence and restoration?

    fwelland

      Hi,

       

      I have MDB that gets a message and creates a Timer in the onMessage() method.     The MDB class also implements TimedObject too.  Pretty much everything works as expected; ejbTimeout() fires upon time expiration of the Timer created in onMessage() invocation.

       

      So now I want timer to persist  (oh JBOSS 5.1.0ga -- using a slightly/insignificantly modified version of 'standard' profile) and then expire (calling ejbTimeout()) after a server restart or crash.  

       

      So I did nothing -- as it looks like by default persistence is 'on' for Timers.  I made a new timer and shut down JBOSS (gracefully) before the timer expired.   I restarted JBOSS (no deployment changes) -- ejbTimeout() never happended.

       

      Ok so I updated ejb2-timer-service.xml to use a different data source that points to an Oracle DB.    And now I could actually see the TIMERS table and I can see records come and go.    Great!  

       

      So I retested my restart case - the timer record gets in DB -- jboss goes down -- I restart JBOSS -- no expiration.    Hmm...I am not doing it correctly...

       

      I fiddle around in JMX console and find the resetAndRestoreTimers() operation on the TimerService MBean.  I invoke.    The TIMER record goes away from DB and I get an error like:

       

      13:41:23,338 WARN  [DatabasePersistencePolicy] Unable to restore timer record: [id=1264615860179,target=[target=jboss.j2ee:jndiName=local/DillyDallyMDB@26175815,service=EJB],first=27-Jan-2010 13:12:34.261,periode=0]

       

      I think this means something like the EJB that is suppose to get the Expiry notice  (local/DillyDallyMDB@26175815 , perhaps??)  can't be found.    Which sorta make sence as when I restarted, although I didn't change anything -- that instance is gone (but there is a new one -- just not with that complete name??). 

       

       

      So  can I work around this? 

       

      Do I have a fundamental mis-understanding of the TIMER service and persistence?

       

      If it can be fixed, is there a way that resetAndRestoreTimers() can just happen on startup?  

       

      Should I not be use a combined MDB and TimedObject implementation?

       

      I deployed my MDB as if it were a normal MDB I didnt' do anything magical in DD.  Is something suppose to be in DD that says, 'this is the target of a timer'?

       

      Any other guidance?

        • 1. Re: Timer Persistence and restoration?
          jaikiran

          fwelland wrote:

           


           

          I think this means something like the EJB that is suppose to get the Expiry notice  (local/DillyDallyMDB@26175815 , perhaps??)  can't be found.    Which sorta make sence as when I restarted, although I didn't change anything -- that instance is gone (but there is a new one -- just not with that complete name??). 

           

           

          So  can I work around this? 

           

          Use the local-jndi-name to fix the randomness. See this for details http://community.jboss.org/wiki/WhyDoesTheLocalNameContainARandomNumber

          • 2. Re: Timer Persistence and restoration?
            fwelland

            Hmm thanks for the tip! 

             

            I must be doing something wrong -- as I put in <local-jndi-name>DillyDallyMDB</local-jndi-name> in jboss.xml and redeployed my MDB.

             

            The MDB created the timer correctly.      However, the TIMERs table still had the "@hascode" appended to end of jndi name.

             

             

            Is there something I need to change in the ejb timer service that says use the local jndi name not the global one with the hash in it?

             

             

             

            (THANKS  -- I think I am getting closer!!)

            • 3. Re: Timer Persistence and restoration?
              fwelland

              Thanks a Kabillion!    That worked!

               

              I had a mistake in my DD/jboss.xml  by having the <local-jndi-name>DillyDallyMDB</local-jndi-name> before my activation config. 

               

              Not exactly sure how I missed this on my first few tests....

               

              -----------------------

              I don't think it is related but I also switched my persistence adapter from the general to oracle in my ejb2 timer file.    I did this switch at the same time that I did the correctiong jboss.xml.    I think it was the jboss.xml that fixed it and nothing to do with the oracle persistence adapter...

               

              Thanks again!