com.google.appengine.api.taskqueue.TaskOptions Java Examples

The following examples show how to use com.google.appengine.api.taskqueue.TaskOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BigqueryPollJobActionTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_enqueuePollTask_withChainedTask() throws Exception {
  TaskOptions chainedTask = TaskOptions.Builder
      .withUrl("/_dr/something")
      .method(Method.POST)
      .header("X-Testing", "foo")
      .param("testing", "bar");
  new BigqueryPollJobEnqueuer(TASK_QUEUE_UTILS).enqueuePollTask(
      new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID),
      chainedTask,
      getQueue(CHAINED_QUEUE_NAME));
  assertTasksEnqueued(BigqueryPollJobAction.QUEUE, newPollJobTaskMatcher("POST"));
  TaskStateInfo taskInfo = getOnlyElement(
      TaskQueueHelper.getQueueInfo(BigqueryPollJobAction.QUEUE).getTaskInfo());
  ByteArrayInputStream taskBodyBytes = new ByteArrayInputStream(taskInfo.getBodyAsBytes());
  TaskOptions taskOptions = (TaskOptions) new ObjectInputStream(taskBodyBytes).readObject();
  assertThat(taskOptions).isEqualTo(chainedTask);
}
 
Example #2
Source File: SomeRequestServlet.java    From java-docs-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

  // Increment the count for the current namespace asynchronously.
  QueueFactory.getDefaultQueue()
      .add(TaskOptions.Builder.withUrl("/_ah/update_count").param("countName", "SomeRequest"));
  // Increment the global count and set the
  // namespace locally.  The namespace is
  // transferred to the invoked request and
  // executed asynchronously.
  String namespace = NamespaceManager.get();
  try {
    NamespaceManager.set("-global-");
    QueueFactory.getDefaultQueue()
        .add(TaskOptions.Builder.withUrl("/_ah/update_count").param("countName", "SomeRequest"));
  } finally {
    NamespaceManager.set(namespace);
  }
  resp.setContentType("text/plain");
  resp.getWriter().println("Counts are being updated.");
}
 
Example #3
Source File: TaskQueueServlet.java    From appengine-java-vm-runtime with Apache License 2.0 6 votes vote down vote up
private static void deferredTask(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  String queue = req.getParameter("queue");
  Queue q;
  if (queue == null) {
    q = QueueFactory.getDefaultQueue();
  } else {
    q = QueueFactory.getQueue(queue);
  }
  final String data = req.getParameter("deferredData");

  TaskOptions opts =
      TaskOptions.Builder.withPayload(
          new DeferredTask() {
            @Override
            public void run() {
              gotCalledBack(data);
            }
          });

  latch = new CountDownLatch(1);
  TaskHandle handle = q.add(opts);
  resp.getWriter().print(handle.getQueueName());
}
 
Example #4
Source File: AppEngineTaskQueue.java    From appengine-pipelines with Apache License 2.0 6 votes vote down vote up
List<TaskHandle> addToQueue(final Collection<Task> tasks) {
  List<TaskHandle> handles = new ArrayList<>();
  Map<String, List<TaskOptions>> queueNameToTaskOptions = new HashMap<>();
  for (Task task : tasks) {
    logger.finest("Enqueueing: " + task);
    String queueName = task.getQueueSettings().getOnQueue();
    TaskOptions taskOptions = toTaskOptions(task);
    List<TaskOptions> taskOptionsList = queueNameToTaskOptions.get(queueName);
    if (taskOptionsList == null) {
      taskOptionsList = new ArrayList<>();
      queueNameToTaskOptions.put(queueName, taskOptionsList);
    }
    taskOptionsList.add(taskOptions);
  }
  for (Map.Entry<String, List<TaskOptions>> entry : queueNameToTaskOptions.entrySet()) {
    Queue queue = getQueue(entry.getKey());
    handles.addAll(addToQueue(queue, entry.getValue()));
  }
  return handles;
}
 
Example #5
Source File: TaskQueueTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testCountdownMillis() {
    String testMethodTag = "testCountdownMillis";
    int countdownMillis = 10000;
    TaskOptions taskoptions = TaskOptions.Builder
        .withMethod(TaskOptions.Method.POST)
        .param(TEST_RUN_ID, testRunId)
        .param(TEST_METHOD_TAG, testMethodTag)
        .countdownMillis(countdownMillis);

    long etaMillis = System.currentTimeMillis() + countdownMillis;
    QueueFactory.getQueue(E2E_TESTING_EXEC).add(taskoptions);

    Entity entity = dsUtil.waitForTaskThenFetchEntity(waitInterval, retryMax, testMethodTag);
    long executedAt = (Long) entity.getProperty(EXECUTED_AT);
    Assert.assertTrue("Expected executed_at to be >= " + etaMillis + ", but was: " + executedAt, executedAt >= etaMillis);
}
 
Example #6
Source File: TasksTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #7
Source File: SmokeTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasics() throws Exception {
    final Queue queue = QueueFactory.getQueue("pull-queue");
    sync(2000L);
    TaskHandle th = queue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.PULL).param("foo", "bar".getBytes()));
    try {
        List<TaskHandle> handles = queue.leaseTasks(30, TimeUnit.MINUTES, 100);
        Assert.assertFalse(handles.isEmpty());
        Assert.assertEquals(1, handles.size());
        TaskHandle lh = handles.get(0);
        Assert.assertEquals(th.getName(), lh.getName());
        sync(5000L);
    } finally {
        queue.deleteTask(th);
    }
}
 
Example #8
Source File: TaskQueueTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskNameSpecified() {
    // Add Task with specified name.
    String taskName = "This_is_my_task_name_" + testRunId;
    String testMethodTag = "testTaskNameSpecified";
    TaskOptions optionsHasName = TaskOptions.Builder
        .withMethod(TaskOptions.Method.POST)
        .param(TEST_RUN_ID, testRunId)
        .param(TEST_METHOD_TAG, testMethodTag)
        .taskName(taskName)
        .url("/queuetask/addentity")
        .etaMillis(0);

    QueueFactory.getQueue(E2E_TESTING).add(optionsHasName);
    Entity entity = dsUtil.waitForTaskThenFetchEntity(waitInterval, retryMax, testMethodTag);
    Map<String, String> expectedParams = dsUtil.createParamMap(testMethodTag);
    expectedParams.put("X-AppEngine-TaskName", taskName);
    dsUtil.assertTaskParamsMatchEntityProperties(expectedParams, entity);
}
 
Example #9
Source File: AsyncTaskEnqueuer.java    From nomulus with Apache License 2.0 6 votes vote down vote up
/** Enqueues a task to asynchronously delete a contact or host, by key. */
public void enqueueAsyncDelete(
    EppResource resourceToDelete,
    DateTime now,
    String requestingClientId,
    Trid trid,
    boolean isSuperuser) {
  Key<EppResource> resourceKey = Key.create(resourceToDelete);
  logger.atInfo().log(
      "Enqueuing async deletion of %s on behalf of registrar %s.",
      resourceKey, requestingClientId);
  TaskOptions task =
      TaskOptions.Builder.withMethod(Method.PULL)
          .countdownMillis(asyncDeleteDelay.getMillis())
          .param(PARAM_RESOURCE_KEY, resourceKey.getString())
          .param(PARAM_REQUESTING_CLIENT_ID, requestingClientId)
          .param(PARAM_SERVER_TRANSACTION_ID, trid.getServerTransactionId())
          .param(PARAM_IS_SUPERUSER, Boolean.toString(isSuperuser))
          .param(PARAM_REQUESTED_TIME, now.toString());
  trid.getClientTransactionId()
      .ifPresent(clTrid -> task.param(PARAM_CLIENT_TRANSACTION_ID, clTrid));
  addTaskToQueueWithRetry(asyncDeletePullQueue, task);
}
 
Example #10
Source File: ReadDnsQueueActionTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_corruptTaskTldMismatch_published() {
  // TODO(mcilwain): what's the correct action to take in this case?
  dnsQueue.addDomainRefreshTask("domain.com");
  dnsQueue.addDomainRefreshTask("domain.example");
  QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
      .add(
          TaskOptions.Builder.withDefaults()
              .method(Method.PULL)
              .param(DNS_TARGET_TYPE_PARAM, TargetType.DOMAIN.toString())
              .param(DNS_TARGET_NAME_PARAM, "domain.wrongtld")
              .param(DNS_TARGET_CREATE_TIME_PARAM, "3000-01-01TZ")
              .param(PARAM_TLD, "net"));

  run();

  assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
  assertTldsEnqueuedInPushQueue(
      ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter", "net", "netWriter"));
}
 
Example #11
Source File: DeferredTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeferredUserNS() {
    String testMethodTag = "testDeferredUserNS";
    String specifiedNameSpace = "the_testDeferredUserNS";
    Map<String, String> paramMap = dsUtil.createParamMap(testMethodTag);

    NamespaceManager.set(specifiedNameSpace);

    TaskOptions taskOptions = TaskOptions.Builder.withPayload(new ExecDeferred(dsUtil, paramMap));

    // no task name specified.
    QueueFactory.getQueue(E2E_TESTING_DEFERRED).add(taskOptions);
    Entity entity = dsUtil.waitForTaskThenFetchEntity(waitInterval, retryMax, testMethodTag);

    Map<String, String> expectedMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    expectedMap.putAll(paramMap);
    expectedMap.put("X-AppEngine-Current-Namespace", specifiedNameSpace);

    dsUtil.assertTaskParamsMatchEntityProperties(expectedMap, entity);
}
 
Example #12
Source File: PullQueueAsyncTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testEtaMillis() {
    String tag = "testEtaMillis_" + getTimeStampRandom();
    waitOnFuture(queue.addAsync(TaskOptions.Builder.withMethod(PULL).etaMillis(System.currentTimeMillis() + 15000).tag(tag)));
    sleep(5000);  // Give tasks a chance to become available.

    List<TaskHandle> tasks = waitOnFuture(queue.leaseTasksAsync(LeaseOptions.Builder.withTag(tag).leasePeriod(1, TimeUnit.SECONDS).countLimit(1)));
    assertEquals(0, tasks.size());

    sleep(10000);

    tasks = waitOnFuture(queue.leaseTasksAsync(LeaseOptions.Builder.withTag(tag).leasePeriod(1, TimeUnit.SECONDS).countLimit(1)));
    assertEquals(1, tasks.size());

    waitOnFuture(queue.deleteTaskAsync(tasks));
}
 
Example #13
Source File: TaskQueueUtilsTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteTasks_usesMultipleBatches() {
  Queue defaultQ = QueueFactory.getQueue("default");
  TaskOptions taskOptA = withUrl("/a").taskName("a");
  TaskOptions taskOptB = withUrl("/b").taskName("b");
  TaskOptions taskOptC = withUrl("/c").taskName("c");
  taskQueueUtils.enqueue(defaultQ, ImmutableList.of(taskOptA, taskOptB, taskOptC));
  assertThat(getQueueInfo("default").getTaskInfo()).hasSize(3);

  taskQueueUtils.deleteTasks(
      defaultQ,
      ImmutableList.of(
          new TaskHandle(taskOptA, "default"),
          new TaskHandle(taskOptB, "default"),
          new TaskHandle(taskOptC, "default")));
  assertThat(getQueueInfo("default").getTaskInfo()).hasSize(0);
}
 
Example #14
Source File: ReadDnsQueueActionTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_corruptTaskNoName_discarded() {
  dnsQueue.addDomainRefreshTask("domain.com");
  dnsQueue.addDomainRefreshTask("domain.example");
  QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
      .add(
          TaskOptions.Builder.withDefaults()
              .method(Method.PULL)
              .param(DNS_TARGET_TYPE_PARAM, TargetType.DOMAIN.toString())
              .param(PARAM_TLD, "net"));

  run();

  // The corrupt task isn't in the pull queue, but also isn't in the push queue
  assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
  assertTldsEnqueuedInPushQueue(
      ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter"));
}
 
Example #15
Source File: AsyncTasksTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #16
Source File: ReadDnsQueueActionTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_corruptTaskNoType_discarded() {
  dnsQueue.addDomainRefreshTask("domain.com");
  dnsQueue.addDomainRefreshTask("domain.example");
  QueueFactory.getQueue(DNS_PULL_QUEUE_NAME)
      .add(
          TaskOptions.Builder.withDefaults()
              .method(Method.PULL)
              .param(DNS_TARGET_NAME_PARAM, "domain.net")
              .param(PARAM_TLD, "net"));

  run();

  // The corrupt task isn't in the pull queue, but also isn't in the push queue
  assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
  assertTldsEnqueuedInPushQueue(
      ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter"));
}
 
Example #17
Source File: TaskQueueTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetryOption() {
    String testMethodTag = "testRetryOption";
    RetryOptions retryOptions = new RetryOptions(RetryOptions.Builder.withDefaults())
        .taskRetryLimit(5)
        .taskAgeLimitSeconds(10)
        .maxBackoffSeconds(10)
        .maxDoublings(10)
        .minBackoffSeconds(10);

    TaskOptions taskOptions = TaskOptions.Builder
        .withMethod(TaskOptions.Method.POST)
        .param(TEST_RUN_ID, testRunId)
        .param(TEST_METHOD_TAG, testMethodTag)
        .retryOptions(retryOptions)
        .url("/queuetask/addentity");

    QueueFactory.getQueue(E2E_TESTING).add(taskOptions);
    Entity entity = dsUtil.waitForTaskThenFetchEntity(waitInterval, retryMax, testMethodTag);
    Map<String, String> expectedParams = dsUtil.createParamMap(testMethodTag);
    dsUtil.assertTaskParamsMatchEntityProperties(expectedParams, entity);
}
 
Example #18
Source File: SubscriptionUtility.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Enqueues subscription ids in task queue for deletion.
 *
 * @param subIds Psi subscription ids to be deleted
 */
protected static void enqueueDeletePsiSubscription(String[] subIds) {
  Queue deviceTokenCleanupQueue = QueueFactory.getQueue("subscription-removal");
  deviceTokenCleanupQueue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.POST)
      .url("/admin/push/devicesubscription/delete")
      .param("subIds", new Gson().toJson(subIds, String[].class))
      .param("type", SubscriptionUtility.REQUEST_TYPE_PSI_SUB));
}
 
Example #19
Source File: DeviceSubscription.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Enqueues device subscription entity to be deleted.
 *
 * @param time Threshold time before which entities created will be deleted
 * @param cursor Query cursor indicates query result position
 */
protected void enqueueDeleteDeviceSubscription(Date time, String cursor) {
  Queue deviceTokenCleanupQueue = QueueFactory.getQueue("subscription-removal");
  deviceTokenCleanupQueue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.POST)
      .url("/admin/push/devicesubscription/delete")
      .param("timeStamp", new Gson().toJson(time, Date.class))
      .param("cursor", cursor)
      .param("type", SubscriptionUtility.REQUEST_TYPE_DEVICE_SUB));
}
 
Example #20
Source File: TasksTest.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
private void assertServletReceivesCorrectMethod(TaskOptions.Method method) {
    MethodRequestHandler handler = new MethodRequestHandler();
    PrintServlet.setRequestHandler(handler);

    Queue queue = QueueFactory.getQueue("tasks-queue");
    queue.add(withUrl(URL).method(method));
    sync();

    assertEquals("Servlet received invalid HTTP method.", method.name(), handler.method);
}
 
Example #21
Source File: SubscriptionUtility.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
/**
 * Enqueues subscription ids in task queue for deletion.
 *
 * @param subIds Psi subscription ids to be deleted
 */
protected static void enqueueDeletePsiSubscription(String[] subIds) {
  Queue deviceTokenCleanupQueue = QueueFactory.getQueue("subscription-removal");
  deviceTokenCleanupQueue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.POST)
      .url("/admin/push/devicesubscription/delete")
      .param("subIds", new Gson().toJson(subIds, String[].class))
      .param("type", SubscriptionUtility.REQUEST_TYPE_PSI_SUB));
}
 
Example #22
Source File: TaskQueueTest.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testAddingTwoTasksWithSameNameInSingleRequestThrowsException() {
    String taskName = "sameName2";
    getDefaultQueue().add(
        Arrays.asList(
            TaskOptions.Builder.withTaskName(taskName),
            TaskOptions.Builder.withTaskName(taskName)));
}
 
Example #23
Source File: TxTaskQueueTest.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoTaskIterable() {
    assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);

    Transaction tx = DatastoreServiceFactory.getDatastoreService().beginTransaction();
    final int beforeNumTasks = getDefaultQueue().fetchStatistics().getNumTasks();
    try {
        getDefaultQueue().add(tx, Collections.singleton(TaskOptions.Builder.withDefaults()));
    } finally {
        tx.rollback();
    }

    sync(10000);  // Wait for statistics servers to refresh.
    Assert.assertEquals(beforeNumTasks, getDefaultQueue().fetchStatistics().getNumTasks());
}
 
Example #24
Source File: TaskQueueTest.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
@Test(expected = TaskAlreadyExistsException.class)
public void testAddingTwoTasksWithSameNameThrowsException() {
    String taskName = "sameName";
    Queue queue = getDefaultQueue();
    // TODO -- perhaps change this with delay on servlet side?
    queue.add(TaskOptions.Builder.withTaskName(taskName).countdownMillis(10 * 1000L));
    queue.add(TaskOptions.Builder.withTaskName(taskName));
}
 
Example #25
Source File: DeviceSubscription.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
/**
 * Enqueues device subscription entity to be deleted.
 *
 * @param time Threshold time before which entities created will be deleted
 * @param cursor Query cursor indicates query result position
 */
protected void enqueueDeleteDeviceSubscription(Date time, String cursor) {
  Queue deviceTokenCleanupQueue = QueueFactory.getQueue("subscription-removal");
  deviceTokenCleanupQueue.add(TaskOptions.Builder.withMethod(TaskOptions.Method.POST)
      .url("/admin/push/devicesubscription/delete")
      .param("timeStamp", new Gson().toJson(time, Date.class))
      .param("cursor", cursor)
      .param("type", SubscriptionUtility.REQUEST_TYPE_DEVICE_SUB));
}
 
Example #26
Source File: TransactionsTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void transactionalTaskEnqueuing() throws Exception {
  // [START transactional_task_enqueuing]
  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  Queue queue = QueueFactory.getDefaultQueue();
  Transaction txn = datastore.beginTransaction();
  // ...

  queue.add(txn, TaskOptions.Builder.withUrl("/path/to/handler"));

  // ...

  txn.commit();
  // [END transactional_task_enqueuing]
}
 
Example #27
Source File: DeferredTaskTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskGetsRun() throws InterruptedException {
  QueueFactory.getDefaultQueue().add(
      TaskOptions.Builder.withPayload(new MyTask()));
  assertTrue(latch.await(5, TimeUnit.SECONDS));
  assertTrue(MyTask.taskRan);
}
 
Example #28
Source File: TaskQueueConfigTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private void doTest() throws InterruptedException {
  // [START QueueFactory]
  QueueFactory.getQueue("my-queue-name").add(TaskOptions.Builder.withTaskName("task29"));
  // [END QueueFactory]
  // Give the task time to execute if tasks are actually enabled (which they
  // aren't, but that's part of the test).
  Thread.sleep(1000);
  LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
  QueueStateInfo qsi =
      ltq.getQueueStateInfo().get(QueueFactory.getQueue("my-queue-name").getQueueName());
  assertEquals(1, qsi.getTaskInfo().size());
  assertEquals("task29", qsi.getTaskInfo().get(0).getTaskName());
}
 
Example #29
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public void checkUpgrade(String userId) {
  if (!conversionEnabled)     // Unless conversion is enabled...
    return;
  Objectify datastore = ObjectifyService.begin();
  UserData userData = datastore.find(userKey(userId));
  if ((userData.upgradedGCS && useGcs) ||
    (!userData.upgradedGCS && !useGcs))
    return;                   // All done.
  Queue queue = QueueFactory.getQueue("blobupgrade");
  queue.add(TaskOptions.Builder.withUrl("/convert").param("user", userId)
    .etaMillis(System.currentTimeMillis() + 60000));
  return;
}
 
Example #30
Source File: EmailServiceImpl.java    From tech-gallery with Apache License 2.0 5 votes vote down vote up
/**
 * Push email to queue.
 */
public void push(EmailConfig email) {
  QueueFactory.getQueue(queueName).add(
      TaskOptions.Builder.withUrl(queueUrl).param("subject", email.getSubject())
          .param("body", email.getBody()).param("reason", email.getReason())
          .param("to", email.getTo()[0]));
}