Cron job for Google Appengine Endpoints

南楼画角 提交于 2019-12-12 01:27:02

问题


I like to add cron job for Google Appengine Endpoints.

But in the document for the Endpoints mentioned that we cant add cron job for the GAE Endpoint.

From Document: You cannot call a Google Cloud Endpoint directly from a push task queue or a cron job. GAE Endpoint Source: https://cloud.google.com/appengine/docs/java/endpoints/

Is there a way to add cron job for the endpoint?

Cron Source: https://cloud.google.com/appengine/docs/java/config/cron


回答1:


You'll need to split the logic from your endpoint method out into a separate function or class.

You can then call that separate function/class from both a standard servlet AND the endpoints handler - this way both the servlet and the endpoint call the exact same code.

Then, in your web.xml you'll need to make sure that the URL for the servlet that will be called by cron is only accessible to admin users, then in your cron config you just tell cron to call the admin-protected URL.

Bit of a faff but works.




回答2:


Does your cron need to call one of your Endpoints method ? If yes, you need to put the method's code in a separate task (or a separate webapp2 handler), which can then be called by both the cron and the Endpoints method.



来源:https://stackoverflow.com/questions/36305948/cron-job-for-google-appengine-endpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!