当前位置: 首页>>代码示例>>Java>>正文


Java TaskOptions.etaMillis方法代码示例

本文整理汇总了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());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:17,代码来源:AsyncTasksTest.java

示例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());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:17,代码来源:TasksTest.java

示例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);
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:44,代码来源:QueueHelper.java

示例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());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:46,代码来源:TaskQueueServlet.java


注:本文中的com.google.appengine.api.taskqueue.TaskOptions.etaMillis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。