Package com.google.appengine.api.labs.taskqueue

Examples of com.google.appengine.api.labs.taskqueue.Queue


    return "mq-high";
  }
 
  @Override
  public void publish(Message message) {
    Queue queue = getSystemService().getQueue(getQueueName(message));
    if (message.getTopic() == null) {
      logger.error("Topic is null in message " + message);
      return;
    }
    queue.add(url(MessageQueueServlet.MQ_URL)
        .param("message", Base64.encodeBase64(StreamUtil.toBytes(message))));
  }
View Full Code Here


    }
    DatastoreService service = DatastoreServiceFactory.getDatastoreService();
    service.put(list);

    Queue queue = QueueFactory.getDefaultQueue();
    // Call the next chain.
    queue.add(TaskOptions.Builder.url(request.getRequestURI()).param(
      "count",
      String.valueOf(count + 1)).param("max", max.toString()).param("kind", kind).method(
      Method.GET));

    return null;
View Full Code Here

    groupEventsByChapterId(request, events, options);
    groupEventsByCountry(request, events, options);
    groupEventsByTopic(request, events, options);

    if (events != null && events.size() > 0) {
      Queue queue = QueueFactory.getDefaultQueue();
      queue.add(options);
    }

    query.closeAll();
    pm.close();
View Full Code Here

    countChapters(request, chapters, options);
    countCountries(request, chapters, options);

    if (chapters != null && chapters.size() > 0) {
      Queue queue = QueueFactory.getDefaultQueue();
      queue.add(options);
    }

    query.closeAll();
    pm.close();
View Full Code Here


  @RequestMapping("/offline/generateStats")
  public ModelAndView handleRequest(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    Queue queue = QueueFactory.getDefaultQueue();
    queue.add(TaskOptions.Builder.url("/offline/getChapterStats"));
    queue.add(TaskOptions.Builder.url("/offline/getEventStats"));

    return null;
  }
View Full Code Here

  private final static String CONN_URL = "/appwrench/queuehandler";
 
 
  public void addTaskToQueue(Map<String, String> params) {
    // System.out.println("PRE_TASK_ADDING");
    Queue tq = QueueFactory.getQueue("onPositiveQueue");
    TaskOptions to = TaskOptions.Builder.url(CONN_URL);
    for (String k : params.keySet()) {
      String val = params.get(k);
      to = to.param(k, val);
    }
    to = to.method(Method.POST);
    // to = to.taskName("task" + INIT + "count" + (-1));
    tq.add(to);
    // System.out.println("TASK_ADDED");
    new NewAccess().addTaskToQueue(params);
  }
View Full Code Here

  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      Query query = pm.newQuery(IssueJdoEntry.class);
      List<IssueJdoEntry> list = (List<IssueJdoEntry>) query.execute();
      Queue queue = QueueFactory.getDefaultQueue();
      for (IssueJdoEntry issueJdoEntry : list) {
        String projectName = issueJdoEntry.getProjectName();
        String robotAddress = robot.getRobotName() + "@appspot.com";

        String domain = issueJdoEntry.getDomain();
        String waveId = issueJdoEntry.getWaveId();
        String waveletId = issueJdoEntry.getWaveletId();
        log.info("wave id = " + waveId);
        log.info("wavelet id = " + waveletId);

        JSONObject json = new JSONObject();
        json.put("domain", domain);
        json.put("waveId", waveId);
        json.put("waveletId", waveletId);
        json.put("robotAddress", robotAddress);
        json.put("projectName", projectName);

        TaskOptions taskOptions = TaskOptions.Builder.url("/updateIssueTask").method(Method.POST)
            .payload(json.toString());

        queue.add(taskOptions);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    } finally {
      pm.close();
View Full Code Here

                parameters, "workerRoot", String.class, "worker");
        OutboundBinding outboundBinding = resolveAndRemoveReferenceParameter(
                parameters, "outboundBindingRef", OutboundBinding.class, new GTaskBinding());
        InboundBinding inboundBinding = resolveAndRemoveReferenceParameter(
                parameters, "inboundBindingRef", InboundBinding.class, new GTaskBinding());
        Queue queue = resolveAndRemoveReferenceParameter(
                parameters, "queueRef", Queue.class, QueueFactory.getQueue(remaining));
        GTaskEndpointInfo info = new GTaskEndpointInfo(uri, remaining);
        GTaskEndpoint endpoint = (GTaskEndpoint)super.createEndpoint(
            info.getCanonicalUri(),
            info.getCanonicalUriPath(),
View Full Code Here

    List<Key> putKeys = null;
    try {
      // Prepare control table.
      Key controlId = datastore.allocateIds("dump", 1).getStart();
      List<Entity> list = new ArrayList<Entity>();
      Queue queue = QueueFactory.getDefaultQueue();
      List<TaskOptions> taskList = Lists.newArrayList();
      int countDown = 10000;
      for (int i = 0; i < kinds.length; i++) {
        Key childKey = KeyFactory.createKey(controlId, GbControl.NAME, kinds[i]);
        Entity control = new Entity(childKey);
        control.setProperty(GbControl.KIND_NAME, kinds[i]);
        control.setProperty(GbControl.COUNT, 0);
        if (currentUser != null) {
          control.setProperty(GbControl.REPORT_TO, new Email(currentUser.getEmail()));
        }
        control.setProperty(GbControl.AUTH_SUB_TOKEN, token);
        control.setProperty(GbControl.SPREADSHEET_KEY, spreadsheet.getKey());
        control.setProperty(GbControl.UPDATE_DATE, new Date());
        list.add(control);

        // Start task queue chain for each kind.
        taskList
          .add(TaskOptions.Builder.url("/tasks/dump.gobo").param(
            "controlKey",
            KeyFactory.keyToString(childKey)).countdownMillis(countDown).method(
            Method.GET));

        // to avoid the collision on the spreadsheet.
        countDown += 500;
      }
      putKeys = datastore.put(list);
      queue.add(taskList);

    } catch (Exception e) {
      if (putKeys != null) {
        try {
          datastore.delete(putKeys);
View Full Code Here

    final Key controlKey = asKey("controlKey");
    Entity control = datastore.get(controlKey);
    final String kind = (String) control.getProperty(GbControl.KIND_NAME);
    final Long rowNum = (Long) control.getProperty(GbControl.COUNT);
    logger.info("Drop:kind=" + kind + ":rowNum=" + rowNum);
    Queue queue = QueueFactory.getDefaultQueue();

    FetchOptions withLimit = FetchOptions.Builder.withLimit(RANGE);
    List<Entity> keyList = datastore.prepare(new Query(kind).setKeysOnly()).asList(withLimit);

    if ((keyList == null) || (keyList.size() == 0)) {
      queue.add(TaskOptions.Builder.url("/tasks/dropEnd.gobo").param(
        "controlKey",
        KeyFactory.keyToString(controlKey)).method(Method.GET));
      return null;
    }

    // Delete rows.
    List<Key> delKeyList = new ArrayList<Key>();
    for (Entity entity : keyList) {
      delKeyList.add(entity.getKey());
    }
    datastore.delete(delKeyList);

    // Update the control table.
    control.setProperty(GbControl.COUNT, rowNum + RANGE);
    control.setProperty(GbControl.UPDATE_DATE, new Date());
    datastore.put(control);

    // Call the next chain.
    queue.add(TaskOptions.Builder.url("/tasks/drop.gobo").param(
      "controlKey",
      KeyFactory.keyToString(controlKey)).method(Method.GET));

    return null;
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.labs.taskqueue.Queue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.