Monitor google app engine cron jobs in console? - java

This might be a dumb question, but, i just can't find cron jobs panel, I've got an app in java and I need to refresh the data every day, so I create this cron.xml inside WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/refreshdata</url>
<description>Daily data refresh cron task </description>
<schedule>every day 05:00</schedule>
</cron>
</cronentries>
I deployed it, but it doesnt work and I cant find the "cron job panel" in console to monitor it or even check if GAE recognizes it...
Documentation says " (You can verify the Cron job you just deployed by clicking Cron Jobs in the left nav pane.) http://i.stack.imgur.com/1niVt.png "
but it doesn't exist anymore, gae's console UI changed, where it is now? I tried in logs without success
it is something wrong with my .xml?
Any help would be apreciated, thanks.

If you are using the new Console for your projects in app engine then this is how it will look like after you have selected a project to view from https://console.developers.google.com/project using your google account.
Hope it helps!

You can find it under Task Queues, you should be able to see Cron as a tab in that view

On Cloud developers console, it should be available at this location:
https://console.developers.google.com/project/your-project-id/appengine/taskqueues?tab=CRON

Related

GAE cron job shuts down unexpectedly

I have some cron jobs configured in cron.xml in an application on Google App Engine.
These jobs work once a day on a version of my application and make some work on the db.
For example a cron job calls v1.myapp.appspot.com...
After some weeks this application instance seems to no longer work correctly. It does not execute the cron jobs as I expect.
On GAE Dashboard I found a section with a list of cron job, but I can't see my cron jobs there.
Why did they disapper? What's wrong with my configuration environment? or Why google stops the execution of my cron jobs?
The cron job configuration is an app-wide scope configuration, it's not a configuration of a specific service/version. Every cron deployment (which can be done without necessarily updating a service/version) will overwrite the previously deployed one.
To avoid accidental errors personally I have a single cron config file at the app level, symlinked inside each service as needed.
If you want to keep the cron job for an older version running you need to add a configuration entry for it with a target matching that service/version, otherwise the cron job will stop working when that version is no longer the default one (as the cron-triggered requests will be directed towards the default service/version):
From Creating a cron job:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/tasks/summary</url>
<target>beta</target>
<description>daily summary job</description>
<schedule>every 24 hours</schedule>
</cron>
</cronentries>
The target specification is optional and is the name of a
service/version. If present, the target is prepended to your app's
hostname, causing the job to be routed to that service/version. If no
target is specified, the job will run in the default version of the
default service.

Periodically update a file in WEB-INF without restarting application - Google App Engine

My Java application in Google App Engine loads a whitelist file stored in /WEB-INF. The file is defined as a resource file in appengine-web.xml:
<resource-files>
<include path="/whitelist.txt" />
</resource-files>
The whitelist is loaded when the first GET request is received.
However, I want to modify the code such that the whitelist is loaded every 15 minutes. This way if I make any changes to the whitelist file (in WEB-INF/whitelist.txt), the changes are reflected soon after.
I tried using a ScheduledExecutorService with a Runnable task as mentioned here https://stackoverflow.com/a/2249068/1244329 where the task consists of just reading the file. However, the task inside contextInitialized is never executed. In fact, I don't think I am even hitting the contextInitialized method.
What am I doing wrong? How should I implement this?
You could use a cron job to execute the whitelist file loading. See Scheduling Tasks With Cron for Java.
But you have another problem: you can't actually change WEB-INF/whitelist.txt without deploying an updated app code, so you can't actually refresh the whitelist info this way without restarting your app.
You could do it, but by storing the file somwewhere else, where you can update it independently of the app deployment, for example in GCS.

How does the JDBCJobStore work .?

So I started to tinker around with JDBCJobStore in Quartz. Firstly, I could not find a single good resource on how to configure it from scratch. After looking for it for a while and singling out a good resource for beginners, I downloaded the sample application at Job scheduling with Quartz. I have a few doubts regarding it.
How does JDBCJobStore capture jobs.? I mean in order for the job to get stored in the database does the job have to run manually once.? Or will JDBCJobStore automatically detect the jobs and their details..?
How does JDBCJobStore schedule the jobs.? Does it hit the database at a fixed interval like a heartbeat to check if there are any scheduled jobs.? Or does it keep the triggers in the memory while the application is running.?
In order to run the jobs will I have to manually specify the details of the job like like name and group and fetch the trigger accordingly.? Is there any alternative to this.?
On each application restart how can I tell the scheduler to start automatically..? Can it be specified somehow.?
If you are using servlet/app server you can start it during startup:
http://quartz-scheduler.org/documentation/quartz-2.2.x/cookbook/ServletInitScheduler
If you are running standalone you have to initialize it manually i think.
You can read more about JobStores here:
http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-09
And about jobs and triggers:
http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-02
http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-03
http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-04
I guess that quartz checks jobs based on time interval to proper work in clusters and distributed systems.

running a cron job just once

how can we schedule a cron job to run just once on google app engine for java?
i tried to set a very large value like every 1000 years but doesnt seems to work.
any other option? syntax used is:
<cron>
<url>/AdHocScriptJob</url>
<description>Run adhoc script</description>
<schedule>every 200 minutes</schedule>
<timezone>Asia/Calcutta</timezone>
</cron>
i tried to look at https://developers.google.com/appengine/docs/java/config/cron
That's what task queues are for: https://developers.google.com/appengine/docs/java/taskqueue/overview
Alternatively, you may delete the cron configuration after the task executes or make your code idempotent (e.g. by mixing it with a pull queue).

Can I invoking java web start in program?

I want to make use of the java web start advantage,but I dont want our customer face the java web start loading Screen,it seems ugly...and also customer maybe not install jre and the jre-install maybe fussy to them..so I want to package our application and jre into setup file using installanywhere. when user start our program,I want to invoking web start API to do the work like version compare,and offer outself loading screen ..
so,Can I invoking web start in my program?and how?
Best regards
L.J.W
I don't think web start is the way you want to go here. You can't change the loading screen, and if you want to access the user's computer in any way you'll have to bother the user with a confirmation, and risk them freaking out and canceling. Just roll your own auto-update; it's definitely not worth using web start just for that.
For the loading screen question:
<jnlp ...>
<information>
<icon kind="splash" href="splash.gif" />
...
</information>
...
</jnlp>
If you're installing your application locally on the user's machine, why would you need to call JWS?

Categories