My problem is this:
Google App Engine allows cron jobs to be active for only 30 seconds before an DeadlineExceededException is thrown. And my app that isn't suited for the google app engine platform from this point of view, needs to call a time-consuming cron job.
One solution that I figured out was to calling another Servlet (Servlet2) and let that Servlet2 do the job for me, Servlet_2 would be a regular Java Servlet.
To achieve that, I was thinking of creating a session from my cron job Servlet_1, call the other Servlet_2, test the session and then let the server do the jobs required and in the end invalidate the session.
The call from Servlet_1 should not be redirecting to Servlet_2, because that will put me back in square one again.
Now to my question: Do you think this will work? And if yes and an DeadlineExceededException acure, would the Servlet_2 stop from working as well, even if I put all the code in the destroy method of the Servlet_2?
my code:
//Servlet_1
try {
HttpSession session = request.getSession(true);
session.setAttribute("referingPage", "server is calling");
request.getRequestDispatcher("/Servlet_2.do").forward(request, response);
}catch(DeadlineExceededException e) {
e.printStackTrace();
}
//Servlet_2
@Override
public void destroy() {
HttpSession session = request.getSession(true);
String value = (String)session.getAttribute("referringPage");
if(value.equals("server is calling")) {
// Do the time demanding stuff
}
session.invalidate();
}
Would be grateful for an answer!