Skip to main content

Timer entries are deleted on server Shutdown

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
arres02
Offline
Joined: 2014-02-03

Hi,

I am trying to work the Timer-Service but somehow I am not successful. I hope to find some help in here.

I am running a Glassfish 4 and configured the resource "jdbc/__TimerPool" to persist into my MySQL database.
All Timers are persisted into my database, but as soon as I shutdown the Glassfish all Timers are deleted from the table.

Does anyone know how to make the timer stay persistet even after server restart?

Thank you very much,
arres

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
f3riyanto
Offline
Joined: 2013-10-23

Hi Arres,

EJB Timer service can be setup into 2 type one persist into database or not.
If you no required to save the scheduler into persistence then set this into false.
Commonly you just need to set the persistence into false.

Persistence is set into true if you are using cluster on multiple instance and server.
So each instance can synchronize the scheduler and avoid duplicate running the same scheduler.

I think you can set this persistence into false.
This is how the persistence can be setup in ejb-jar.xml

<session>
      <ejb-name>DataRateSchedulerBean</ejb-name>
      <ejb-class>com.company.sms.ejb.core.scheduler.DataRateSchedulerBean</ejb-class>
      <session-type>Singleton</session-type>
      <timer>
        <schedule>
          <minute>00</minute>
          <hour>18</hour>
        </schedule>
        <timeout-method>
          <method-name>doWork</method-name>
        </timeout-method>
        <persistent>false</persistent>
      </timer>
      <transaction-type>Bean</transaction-type>
    </session>

Hope this will help you.

Thanks
Ferry

arres02
Offline
Joined: 2014-02-03

Hi Ferry,
thank you for you answer. But I already know how to make the TimerService persist into a database.
My problem is, that as soon I make a redeployment all entries are deleted from the database.
Do you know what I have to do, to make the entries stay available even after a redeployment? I guess it is has something to do with the applicationid.

Thank you,
Arres