Pergunta

I have a cron job written in Java using Timer class. This cron job will query external API and populate mysql database for every one hour. I also have a web application which will query the populated database and retrieve results(based on query of a user). This is working fine in local apache webserver.

Now I want to deploy the webapp and the supporting cron job to jelastic - java based cloud web hosting service. I have tried with deploying simple webapp and its working fine. Now my next task is to have the cron job to populate the database. Can any one help me on how can I achieve this. I am not restricted to jelastic itself and comfortable to move to any service that can serve my job.

Thanks,

Foi útil?

Solução

Native cron support is now available in Jelastic, and might be useful for anyone stumbling across this: http://docs.jelastic.com/cron-job

Quartz is also documented in the Jelastic docs (for anyone looking for more help on how to run scheduled tasks in Java that way): http://docs.jelastic.com/quartz

Outras dicas

I'm from Jelastic and I will try to find a best solution for your case.

You can try to use Quartz libraries, it's pretty easy to schedule tasks right from your code.

Since Jelastic vesrion 1.9.1 there will be a possibility to make and execute cronjobs (*/1 * * * * java -jar test.jar). So you will have an opportunity to run your own .jar files which could contain some code to populate database.

I got solution for my Problem.

I have wrapped the cron job(Written in Java using TimerTask) with controller and jsp page. I have given long string to Request Mapping value so that users of the app will be hidden from accessing it(as the cron job will be re triggered every time the request mapping value accessed).

Hope this will help others who has the same problem.

Thanks

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top