将Cron作业与Appengine Endpoints API配合使用 [英] Use Cron jobs with Appengine Endpoints API

查看:114
本文介绍了将Cron作业与Appengine Endpoints API配合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用google App引擎和Endpoints API的后端。
Api Method之一是一个工作,应该运行每X小时,并做一些逻辑的东西。

I have developed a backend using google App engine and Endpoints API. One of Api Method is a job that should run every X hours and do some logical stuff.

我的问题是如何使用Cron调用这个api方法工作。

my Question is how can i call this api method using Cron Job.

我知道Api方法的URL,我甚至成功使用浏览器打电话给她。
,但是当我尝试用cron作业调用它时,该作业失败,并显示404错误代码。

i know the URL of the Api Method and i even succeed call her using the browser. but when i try call it with the cron job, the job was failed with 404 error code.

这里是cron.xml:

here the cron.xml:

enter code here

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/_ah/api/meetingMatchingEndpoint/v1/matchingProcess</url>
    <description>Matching process</description>
    <schedule>every 1 minutes</schedule>
  </cron>
</cronentries>
enter code here



当我尝试从浏览器调用它,网址:

when i try call it from the browser and succeed i wrote the full URL:

https://acadden-motif-344.appspot.com/_ah/api/meetingMatchingEndpoint/v1/matchingProcess

任何人都可以协助?

感谢

推荐答案

Google Cloud Endpoints的架构它们为您提供了一个精心设计的REST层,覆盖您的实际代码。

Google Cloud Endpoints are architected in a manner such that they provide you a well designed REST layer over your actual code.

我认为,由于Cron作业也在同一个应用程序中运行,因此您最好不要通过调用REST API URL的路径。相反,您应该通过精心设计的Java类来直接调用您的功能,这些类封装了您要调用的功能。

Having said that, I think that since the Cron Job is also running inside of the same application, you should ideally not go through the route of invoking the REST API URL. Instead you should directly invoke your functionality through well designed Java classes that encapsulate the functionality you want to invoke.

这篇关于将Cron作业与Appengine Endpoints API配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆