开发者

Execute Backends using Cron in Google App Engine (Java)

开发者 https://www.devze.com 2023-03-19 05:45 出处:网络
I have a Dynamic Backend setup on GAE which I want to run using cron every 15mins. The problem is cron requires a url that beg开发者_如何学Cins with \"/\". While a backend URL uses the following forma

I have a Dynamic Backend setup on GAE which I want to run using cron every 15mins. The problem is cron requires a url that beg开发者_如何学Cins with "/". While a backend URL uses the following format: http://backendname.yourapp.appspot.com.

I've read in other forums that you could use fetchurl to call your backend but I don't think that's the ideal way. Because that would require you to make your backend publicly accessible.

According to google's documentation: http://code.google.com/appengine/docs/java/backends/overview.html#Public_and_Private_Backends

"Private backends can be accessed by application administrators, instances of the application, and by App Engine APIs and services (such as Task Queue tasks and Cron jobs) without any special configuration."

Has anybody got backends called by declaring it in cron.xml?


Use target tag to specify a backend in your cron.xml.

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/long-task</url>
    <description></description>
    <schedule>every 30 minutes</schedule>
    <target>name-of-the-backend</target>
  </cron>
</cronentries>


urlfetch can be used to access internal-only URLs such as private backends - if that weren't possible, there'd be no way to communicate within your app! A better idea, though, might be to use the Task Queue, which can be configured to run tasks against a backend.


I haven't try google app engine's Backends functions, because its pricing model. However, according to the documents:

http://code.google.com/appengine/docs/python/backends/overview.html#Public_and_Private_Backends

Backends are private by default, since they typically function as a component inside an application, rather than acting as its public face.

I think GAE will automatically hide the backend url from public http visiting (even without the needs to configure the app.yaml). You may test its behavior by logout and access the backend url directly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号