本文整理汇总了Java中com.google.appengine.api.taskqueue.TaskOptions.etaMillis方法的典型用法代码示例。如果您正苦于以下问题:Java TaskOptions.etaMillis方法的具体用法?Java TaskOptions.etaMillis怎么用?Java TaskOptions.etaMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.taskqueue.TaskOptions
的用法示例。
在下文中一共展示了TaskOptions.etaMillis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTaskHandleContainsAllNecessaryProperties
import com.google.appengine.api.taskqueue.TaskOptions; //导入方法依赖的package包/类
@Test
public void testTaskHandleContainsAllNecessaryProperties() throws Exception {
String name = "testTaskHandleContainsAllNecessaryProperties-" + System.currentTimeMillis();
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions options = withTaskName(name).payload("payload");
options.etaMillis(0); // TODO -- remove this once NPE is fixewd
TaskHandle handle = waitOnFuture(queue.addAsync(options));
assertEquals("default", handle.getQueueName());
assertEquals(name, handle.getName());
assertEquals("payload", new String(handle.getPayload(), "UTF-8"));
assertNotNull(handle.getEtaMillis());
assertEquals(0, (int) handle.getRetryCount());
}
示例2: testTaskHandleContainsAllNecessaryProperties
import com.google.appengine.api.taskqueue.TaskOptions; //导入方法依赖的package包/类
@Test
public void testTaskHandleContainsAllNecessaryProperties() throws Exception {
String name = "testTaskHandleContainsAllNecessaryProperties-" + System.currentTimeMillis();
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions options = withTaskName(name).payload("payload");
options.etaMillis(0); // TODO -- remove this once NPE is fixewd
TaskHandle handle = queue.add(options);
assertEquals("default", handle.getQueueName());
assertEquals(name, handle.getName());
assertEquals("payload", new String(handle.getPayload(), "UTF-8"));
assertNotNull(handle.getEtaMillis());
assertEquals(0, (int) handle.getRetryCount());
}
示例3: enqueue
import com.google.appengine.api.taskqueue.TaskOptions; //导入方法依赖的package包/类
public static void enqueue (String url, String action, Request request,
Date eta) {
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions options = TaskOptions.Builder.withMethod(Method.POST)
.url(url).param(REQUEST_KEY, request.toString())
.param(ACTION_KEY, action);
if (eta != null) {
options.etaMillis(eta.getTime());
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE,
"Enquing url [" + url + "] with key [" + REQUEST_KEY + "="
+ request + "], action [" + ACTION_KEY + "="
+ action + "]");
}
int retry = RETRY_COUNT;
do {
try {
queue.add(options);
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Enqueued successfully");
}
// success no need to retry
retry = 0;
} catch (TransientFailureException ex) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning(String.format(
"Could not queue a message because of [%s] - will retry it ["
+ retry + "] more time(s)",
ex.toString()));
}
retry--;
}
} while (retry > 0);
}
示例4: addTask
import com.google.appengine.api.taskqueue.TaskOptions; //导入方法依赖的package包/类
private void addTask(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String queue = req.getParameter("queue");
Queue q;
if (queue == null) {
q = QueueFactory.getDefaultQueue();
} else {
q = QueueFactory.getQueue(queue);
}
TaskOptions.Method method = TaskOptions.Method.valueOf(req.getParameter("httpmethod"));
String url = req.getParameter("taskUrl");
if (url == null) {
url = req.getServletPath();
}
TaskOptions opts =
TaskOptions.Builder.withUrl(url).header("myheader", "blarg29").method(method);
if (method == TaskOptions.Method.POST || method == TaskOptions.Method.PUT) {
opts.payload("this=that");
} else {
opts.param("myparam", "yam28");
}
String execTimeMs = req.getParameter("execTimeMs");
if (execTimeMs != null) {
opts.etaMillis(Long.valueOf(execTimeMs));
}
String requestNamespace = req.getParameter("requestNamespace");
if (requestNamespace != null) {
/* We could override the current environment and set the request namespace
* but that's a little overkill and already tested in
* com.google.appengine.api.taskqueue.TaskQueueTest .
*/
opts.header(DEFAULT_NAMESPACE_HEADER, requestNamespace);
}
String currentNamespace = req.getParameter("currentNamespace");
if (currentNamespace != null) {
/* We could also do this:
* opts.header(CURRENT_NAMESPACE_HEADER, currentNamespace);
*/
NamespaceManager.set(currentNamespace);
}
latch = new CountDownLatch(1);
TaskHandle handle = q.add(opts);
resp.getWriter().print(handle.getQueueName());
}