當前位置: 首頁>>代碼示例>>Java>>正文


Java QueueFactory.getQueue方法代碼示例

本文整理匯總了Java中com.google.appengine.api.taskqueue.QueueFactory.getQueue方法的典型用法代碼示例。如果您正苦於以下問題:Java QueueFactory.getQueue方法的具體用法?Java QueueFactory.getQueue怎麽用?Java QueueFactory.getQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.appengine.api.taskqueue.QueueFactory的用法示例。


在下文中一共展示了QueueFactory.getQueue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scheduleNotificationBuild

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
public static void scheduleNotificationBuild(String objectType, Long id,
		String action) {
	if (objectType == null || objectType.isEmpty()) {
		throw new IllegalArgumentException("No Specified Object Type");
	}

	if (id == null) {
		throw new IllegalArgumentException("No Specified Object Id");
	}

	if (action == null || action.isEmpty()) {
		throw new IllegalArgumentException("No Action Specified");
	}

	// Execute the servlet to pull from the queue
	Queue executionQueue = QueueFactory.getQueue("notification-building");
	executionQueue.add(TaskOptions.Builder
			.withUrl("/notifications/builder/").method(Method.GET)
			.param("objectType", objectType)
			.param("id", String.valueOf(id.longValue()))
			.param("action", action));

}
 
開發者ID:pschuette22,項目名稱:Zeppa-AppEngine,代碼行數:24,代碼來源:NotificationUtility.java

示例2: doGet

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
    Enumeration e = req.getHeaderNames();
    while(e.hasMoreElements()) {
        String param = (String)e.nextElement();
        log.info("header:" + param + req.getHeader(param));
    }

    String cronHeader = req.getHeader("X-Appengine-Cron");
    if(cronHeader == null || !cronHeader.trim().equals("true")) {
        resp.setStatus(403);
        return;
    }

    Queue queue = QueueFactory.getQueue("reaper");
    queue.add(TaskOptions.Builder.withUrl("/reaper"));

}
 
開發者ID:saucenet,項目名稱:sync,代碼行數:19,代碼來源:ReaperCronServlet.java

示例3: reset

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
/**
 * Reset reservations in datastore to match those in RTDB. Reservations in RTDB are used
 * as the source of truth, corresponding reservations in datastore are updated to match
 * those in RTDB. Reservations in RTDB that do not exist in datastore are added to datastore.
 * Reservations that exist in datastore and do not exist in RTDB are updated in datastore
 * with status DELETED.
 *
 * Use of this endpoint should be followed by a user data sync.
 *
 * @param user User making request (injected by Endpoints)
 */
@ApiMethod(name = "reset", path = "reset")
public void reset(User user)
    throws UnauthorizedException {
  if (user == null) {
    throw new UnauthorizedException("Invalid credentials");
  }

  // Add Sync Reservations worker to queue.
  Queue queue = QueueFactory.getQueue("SyncReservationsQueue");

  TaskOptions taskOptions = TaskOptions.Builder
      .withUrl("/queue/syncres")
      .method(Method.GET);
  queue.add(taskOptions);
}
 
開發者ID:google,項目名稱:iosched,代碼行數:27,代碼來源:ReservationsEndpoint.java

示例4: addDeferredTask

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
/**
 * Adds the given task, to be run after the specified time, to the specified queue.
 *
 * @param task the task object containing the details of task to be added
 * @param countdownTime the time delay for the task to be executed
 */
public void addDeferredTask(TaskWrapper task, long countdownTime) {
    Queue requiredQueue = QueueFactory.getQueue(task.getQueueName());
    TaskOptions taskToBeAdded = TaskOptions.Builder.withUrl(task.getWorkerUrl());
    if (countdownTime > 0) {
        taskToBeAdded.countdownMillis(countdownTime);
    }

    for (Map.Entry<String, String[]> entry : task.getParamMap().entrySet()) {
        String name = entry.getKey();
        String[] values = entry.getValue();

        for (String value : values) {
            taskToBeAdded = taskToBeAdded.param(name, value);
        }
    }

    requiredQueue.add(taskToBeAdded);
}
 
開發者ID:TEAMMATES,項目名稱:teammates,代碼行數:25,代碼來源:TaskQueuesLogic.java

示例5: deferredTask

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
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());
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-java-vm-runtime,代碼行數:25,代碼來源:TaskQueueServlet.java

示例6: doPolling

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
private void doPolling() {
  Queue notificationQueue = QueueFactory.getQueue("notification-delivery");

  Worker worker = new Worker(notificationQueue);
  while (!LifecycleManager.getInstance().isShuttingDown()) {
    boolean tasksProcessed = worker.processBatchOfTasks();
    ApiProxy.flushLogs();

    if (!tasksProcessed) {
      // Wait before trying to lease tasks again.
      try {
        Thread.sleep(MILLISECONDS_TO_WAIT_WHEN_NO_TASKS_LEASED);
      } catch (InterruptedException e) {
        return;
      }
    }
  }

  log.info("Instance is shutting down");
}
 
開發者ID:googlesamples,項目名稱:io2014-codelabs,代碼行數:21,代碼來源:WorkerServlet.java

示例7: leaseAndDeleteTasks

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
private void leaseAndDeleteTasks(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
  int numTasks = Integer.parseInt(req.getParameter("numTasks"));
  Double lease = Double.parseDouble(req.getParameter("lease"));
  String queue = req.getParameter("queue");
  Queue q = QueueFactory.getQueue(queue);
  Boolean doDelete = Boolean.parseBoolean(req.getParameter("doDelete"));

  List<TaskHandle> tasks = q.leaseTasks(lease.intValue() * 1000, TimeUnit.MILLISECONDS, numTasks);

  for (TaskHandle task : tasks) {
    if (doDelete) {
      q.deleteTask(task.getName());
    }
  }
  resp.getWriter().print(queue + "," + tasks.size());
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-java-vm-runtime,代碼行數:18,代碼來源:TaskQueueServlet.java

示例8: scheduleNotification

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
@POST
@Path("{patientEmail}")
@Produces({MediaType.TEXT_PLAIN})
public String scheduleNotification(@PathParam("patientEmail") String patientEmail,
                                   @FormParam("calendarId") String calendarId,
                                   @FormParam("eventId") String eventId) throws IOException {
    verifyPatientEmail(patientEmail);
    Event event = getCalendarEvent(patientEmail, calendarId, eventId);
    String appointmentTime = event.getStart().getDateTime().toStringRfc3339();

    TaskOptions task = withUrl("/tasks/notification/")
            .method(TaskOptions.Method.GET)
            .param("patientEmail", patientEmail)
            .param("appointmentAddress", event.getLocation())
            .param("appointmentTime", appointmentTime);

    Queue queue = QueueFactory.getQueue(QUEUE_NAME);
    queue.add(task);

    return "OK";
}
 
開發者ID:openmash,項目名稱:mashmesh,代碼行數:22,代碼來源:SendEventNotificationResource.java

示例9: testPullMultipleWithSameTag

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
@Test
public void testPullMultipleWithSameTag() throws Exception {
    final Queue queue = QueueFactory.getQueue("pull-queue");
    TaskHandle th1 = queue.add(withMethod(PULL).tag("barfoo2").payload("foobar").etaMillis(15000));
    TaskHandle th2 = queue.add(withMethod(PULL).tag("barfoo2").payload("foofoo").etaMillis(10000));
    try {
        List<TaskHandle> handles = waitOnFuture(queue.leaseTasksByTagAsync(30, TimeUnit.MINUTES, 100, "barfoo2"));
        assertEquals(2, handles.size());

        Set<String> expectedTasks = taskHandlesToNameSet(th1, th2);
        Set<String> returnedTasks = taskHandleListToNameSet(handles);
        assertEquals(expectedTasks, returnedTasks);

    } finally {
        queue.deleteTask(th1);
        queue.deleteTask(th2);
    }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:19,代碼來源:PullAsyncTest.java

示例10: testParams

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
@Test
public void testParams() throws Exception {
    class ParamHandler implements PrintServlet.RequestHandler {
        private String paramValue;

        public void handleRequest(ServletRequest req) {
            paramValue = req.getParameter("single_value");
        }
    }

    ParamHandler handler = new ParamHandler();
    PrintServlet.setRequestHandler(handler);

    final Queue queue = QueueFactory.getQueue("tasks-queue");
    queue.add(withUrl(URL).param("single_value", "param_value"));
    sync();

    assertEquals("param_value", handler.paramValue);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:20,代碼來源:TasksTest.java

示例11: doPolling

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
private void doPolling() {
  Queue notificationQueue = QueueFactory.getQueue("notification-delivery");

  PushNotificationWorker worker = new PushNotificationWorker(notificationQueue);
  while (!LifecycleManager.getInstance().isShuttingDown()) {
    boolean tasksProcessed = worker.processBatchOfTasks();
    ApiProxy.flushLogs();

    if (!tasksProcessed) {
      // Wait before trying to lease tasks again.
      try {
        Thread.sleep(MILLISECONDS_TO_WAIT_WHEN_NO_TASKS_LEASED);
      } catch (InterruptedException e) {
        return;
      }
    }
  }

  log.info("Instance is shutting down");
}
 
開發者ID:GoogleCloudPlatform,項目名稱:solutions-ios-push-notification-sample-backend-java,代碼行數:21,代碼來源:PushNotificationWorkerServlet.java

示例12: testRequestHeaders

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
@Test
public void testRequestHeaders() throws Exception {
    String name = "testRequestHeaders-1-" + System.currentTimeMillis();
    Queue defaultQueue = QueueFactory.getDefaultQueue();
    defaultQueue.add(withTaskName(name));
    sync();

    RequestData request = DefaultQueueServlet.getLastRequest();
    assertEquals("default", request.getHeader(QUEUE_NAME));
    assertEquals(name, request.getHeader(TASK_NAME));
    assertNotNull(request.getHeader(TASK_RETRY_COUNT));
    assertNotNull(request.getHeader(TASK_EXECUTION_COUNT));
    assertNotNull(request.getHeader(TASK_ETA));

    String name2 = "testRequestHeaders-2-" + System.currentTimeMillis();
    Queue testQueue = QueueFactory.getQueue("test");
    testQueue.add(withTaskName(name2));
    sync();

    request = TestQueueServlet.getLastRequest();
    assertEquals("test", request.getHeader(QUEUE_NAME));
    assertEquals(name2, request.getHeader(TASK_NAME));
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:24,代碼來源:TasksTest.java

示例13: multicastSend

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
public void multicastSend(List<Device> devices, String action, String extraData) {
    Queue queue = QueueFactory.getQueue("MulticastMessagesQueue");

    // Split messages into batches for multicast
    // GCM limits maximum devices per multicast request. AppEngine also limits the size of
    // lists stored in the datastore.
    int total = devices.size();
    List<String> partialDevices = new ArrayList<String>(total);
    int counter = 0;
    for (Device device : devices) {
        counter ++;
        partialDevices.add(device.getGcmId());
        int partialSize = partialDevices.size();
        if (partialSize == MAX_DEVICES || counter == total) {
            // Send multicast message
            Long multicastKey = MessageStore.createMulticast(partialDevices,
                    action,
                    extraData);
            mLogger.fine("Queuing " + partialSize + " devices on multicast " + multicastKey);
            TaskOptions taskOptions = TaskOptions.Builder
                    .withUrl("/queue/send")
                    .param("multicastKey", Long.toString(multicastKey))
                    .method(TaskOptions.Method.POST);
            queue.add(taskOptions);
            partialDevices.clear();
        }
    }
    mLogger.fine("Queued message to " + total + " devices");
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:30,代碼來源:MessageSender.java

示例14: checkUpgrade

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
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;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:14,代碼來源:ObjectifyStorageIo.java

示例15: createAction

import com.google.appengine.api.taskqueue.QueueFactory; //導入方法依賴的package包/類
private RdeUploadAction createAction(URI uploadUrl) {
  try (Keyring keyring = new FakeKeyringModule().get()) {
    RdeUploadAction action = new RdeUploadAction();
    action.clock = clock;
    action.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
    action.ghostryde = new Ghostryde(BUFFER_SIZE);
    action.lazyJsch =
        () ->
            JSchModule.provideJSch(
                "[email protected]",
                keyring.getRdeSshClientPrivateKey(),
                keyring.getRdeSshClientPublicKey());
    action.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3));
    action.response = response;
    action.pgpCompressionFactory = compressFactory;
    action.pgpEncryptionFactory = encryptFactory;
    action.pgpFileFactory = literalFactory;
    action.pgpSigningFactory = signFactory;
    action.tarFactory = tarFactory;
    action.bucket = "bucket";
    action.interval = standardDays(1);
    action.timeout = standardSeconds(23);
    action.tld = "tld";
    action.sftpCooldown = standardSeconds(7);
    action.uploadUrl = uploadUrl;
    action.receiverKey = keyring.getRdeReceiverKey();
    action.signingKey = keyring.getRdeSigningKey();
    action.stagingDecryptionKey = keyring.getRdeStagingDecryptionKey();
    action.reportQueue = QueueFactory.getQueue("rde-report");
    action.runner = runner;
    action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1));
    action.retrier = new Retrier(new FakeSleeper(clock), 3);
    return action;
  }
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:36,代碼來源:RdeUploadActionTest.java


注:本文中的com.google.appengine.api.taskqueue.QueueFactory.getQueue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。