你如何为GAE的任务引擎中的任务设置ETA? [英] How do you set an ETA for a task in GAE's task engine?

查看:111
本文介绍了你如何为GAE的任务引擎中的任务设置ETA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在未来一小时内完成一项任务。这是我正在做的,似乎并不奏效。

  import static com.google.appengine.api.taskqueue。 TaskOptions.Builder提供*。 


日历cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.HOUR,1);
cal.getTime();

队列队列= QueueFactory.getDefaultQueue();
queue.add(withUrl(/ task / doMyThing)。param(userId,userId).header(X-AppEngine-TaskETA,cal.getTime()。getTime()+) );

-edit



好一点更多的解释:当有人点击我的服务时,我想在他们点击服务后一小时内调用Java方法。我认为任务队列是在App Engine上执行此操作的最佳方式。我认为队列不会执行那个任务,除非ETA已经通过了。如果我接近这个错误的方式,并有更好的方法来完成它,请让我知道。



- 再次编辑



感谢您的答案,以下是我所做的记录:

 队列队列= QueueFactory.getDefaultQueue() ; 
queue.add(withUrl(/ task / sendReminder).param(userId,userId).countdownMillis(120000));


解决方案

我已经完成了您要做的事情但在Python中。我想你试图设置的头文件是appengine在从队列中启动一个任务时设置的,而不一定是在创建任务时设置的头文件。我认为您正在寻找 countdownMillis ,值为3600000。


I'm trying to run a task an hour in the future. Here's what I'm doing, doesn't seem to work.

import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;


Calendar cal = Calendar.getInstance(); 
cal.setTime(new Date()); 
cal.add(Calendar.HOUR, 1); 
cal.getTime(); 

Queue queue = QueueFactory.getDefaultQueue();
queue.add(withUrl("/task/doMyThing").param("userId", userId).header("X-AppEngine-TaskETA", cal.getTime().getTime()+""));

-edit

OK then a little more clarification: When someone hits my service I want to call a Java method exactly an hour after they hit the service. I assumed the task queue was the best way to do that on App Engine. I thought the queue would not execute that task unless the ETA had passed. If I'm approaching this the wrong way and there's a better way to accomplish it please let me know.

-edit again

Thanks for the answers, for the record here's what I did:

Queue queue = QueueFactory.getDefaultQueue();
queue.add(withUrl("/task/sendReminder").param("userId", userId).countdownMillis(120000));

解决方案

I've done what you're trying to do but in python. I think the header you're trying to set is one that appengine sets when it starts a task from the queue and not necessarily one that you set when you're creating the task. I think you're looking for countdownMillis with a value of 3600000.

这篇关于你如何为GAE的任务引擎中的任务设置ETA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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