當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。