当前位置: 首页>>代码示例>>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;未经允许,请勿转载。