Package com.google.appengine.api.taskqueue

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


    List<String> devices = Datastore.getDevices();
    String status;
    if (devices.isEmpty()) {
      status = "Message ignored as there is no device registered!";
    } else {
      Queue queue = QueueFactory.getQueue("gcm");
      // NOTE: check below is for demonstration purposes; a real
      // application
      // could always send a multicast, even for just one recipient
      if (devices.size() == 1) {
        // send a single message using plain post
        String device = devices.get(0);
        queue.add(withUrl("/send").param(
            SendMessageServlet.PARAMETER_DEVICE, device));
        status = "Single message queued for registration id " + device;
      } else {
        // send a multicast message using JSON
        // must split in chunks of 1000 devices (GCM limit)
        int total = devices.size();
        List<String> partialDevices = new ArrayList<String>(total);
        int counter = 0;
        int tasks = 0;
        for (String device : devices) {
          counter++;
          partialDevices.add(device);
          int partialSize = partialDevices.size();
          if (partialSize == Datastore.MULTICAST_SIZE
              || counter == total) {
            String multicastKey = Datastore
                .createMulticast(partialDevices);
            logger.fine("Queuing " + partialSize
                + " devices on multicast " + multicastKey);
            TaskOptions taskOptions = TaskOptions.Builder
                .withUrl("/send")
                .param(SendMessageServlet.PARAMETER_MULTICAST,
                    multicastKey).method(Method.POST);
            queue.add(taskOptions);
            partialDevices.clear();
            tasks++;
          }
        }
        status = "Queued tasks to send " + tasks
View Full Code Here


    StringBuilder respBuilder = new StringBuilder();
   
    Date date = new Date();
    String[] ids = {"air", "bhv", "gw2", "hsb", "uni", "wer"};
   
    Queue queue = QueueFactory.getDefaultQueue();
   
    for(String id: ids) {
      if(taskNameDAO.getTaskName(id) == null) {
        String name = id+"-"+date.getTime();
        TaskOptions taskOpt = TaskOptions.Builder.withUrl("/automatedupdate");
        taskOpt.param("mensa", id);
        taskOpt.method(Method.GET);
        taskOpt.taskName(name);
        queue.add(taskOpt);
        TaskName taskName = new TaskName();
        taskName.setIdentifier(id);
        taskName.setTaskName(name);
        taskNameDAO.saveTaskName(taskName);
       
View Full Code Here

  @Override
  public void enqueue(Task task) {
    logger.finest("Enqueueing: " + task);
    TaskOptions taskOptions = toTaskOptions(task);
    Queue queue = getQueue(task.getQueueSettings().getOnQueue());
    try {
      queue.add(taskOptions);
    } catch (TaskAlreadyExistsException ingore) {
      // ignore
    }
  }
View Full Code Here

        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;
  }
View Full Code Here

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
  {
    response.setContentType("text/plain");
    response.getWriter( ).println("Adding tasks to queue.");
   
    Queue queue = QueueFactory.getQueue("noRetry");
   
    for (int i = 0; i < 3; i++)
    {
      queue.add
      (
        TaskOptions.Builder.withUrl("/insult").method(TaskOptions.Method.GET).countdownMillis(TimeUnit.SECONDS.toMillis(20))/**/
      );
    }
  }
 
View Full Code Here

    public void launchForUpdate(Long userID, Character character) {
        logger.info("Scheduling price set update tasks");
        List<PriceSet> characterPriceSets = priceSetDao.getAll(new Key<User>(User.class, userID), character.getCharacterID());
        for (PriceSet priceSet : characterPriceSets) {
            logger.info("Scheduling price set update task for priceSetID: {}, userID: {}", priceSet.getId(), userID);
            Queue queue = appEngineServices.getQueue(queueName);
            TaskOptions taskOptions = withUrl(TASK_UPDATE_PRICE_SET).param("userID", String.valueOf(userID))
                    .param("priceSetID", String.valueOf(priceSet.getId()))
                    .param("characterID", String.valueOf(character.getCharacterID()))
                    .param("characterName", character.getName());
            if (character.getCorporationID() != null) {
                taskOptions.param("corporationID", String.valueOf(character.getCorporationID()))
                        .param("corporationName", character.getCorporationName())
                        .param("corporationTicker", character.getCorporationTicker());
            }
            if (character.getAllianceID() != null) {
                taskOptions.param("allianceID", String.valueOf(character.getAllianceID()))
                        .param("allianceName", character.getAllianceName());
            }
            queue.add(taskOptions);
        }
    }
View Full Code Here

    public void launchForDetach(Long userID, Character character) {
        logger.info("Scheduling price set update for detach tasks");
        List<PriceSet> characterPriceSets = priceSetDao.getAll(new Key<User>(User.class, userID), character.getCharacterID());
        for (PriceSet priceSet : characterPriceSets) {
            logger.info("Scheduling price set update for detach task for priceSetID: {}, userID: {}", priceSet.getId(), userID);
            Queue queue = appEngineServices.getQueue(queueName);
            TaskOptions taskOptions = withUrl(TASK_UPDATE_PRICE_SET).param("userID", String.valueOf(userID))
                    .param("priceSetID", String.valueOf(priceSet.getId()))
                    .param("characterID", String.valueOf(character.getCharacterID()))
                    .param("characterName", character.getName());
            queue.add(taskOptions);
        }
    }
View Full Code Here

    public void launchForDelete(Long userID, Long characterID) {
        logger.info("Scheduling price set update for delete tasks");
        List<PriceSet> characterPriceSets = priceSetDao.getAll(new Key<User>(User.class, userID), characterID);
        for (PriceSet priceSet : characterPriceSets) {
            logger.info("Scheduling price set update for delete task for priceSetID: {}, userID: {}", priceSet.getId(), userID);
            Queue queue = appEngineServices.getQueue(queueName);
            TaskOptions taskOptions = withUrl(TASK_UPDATE_PRICE_SET).param("userID", String.valueOf(userID))
                    .param("priceSetID", String.valueOf(priceSet.getId()));
            queue.add(taskOptions);
        }
    }
View Full Code Here

        this.queueName = queueName;
    }

    public void launch(Long userID, Long blueprintTypeID, Long itemID, Integer meLevel, Integer peLevel, Long attachedCharacterID, String sharingLevel) {
        logger.info("Scheduling blueprint add task");
        Queue queue = appEngineServices.getQueue(queueName);
        TaskOptions taskOptions = withUrl(TASK_ADD_BLUEPRINT).param("userID", String.valueOf(userID))
                .param("blueprintTypeID", String.valueOf(blueprintTypeID))
                .param("meLevel", String.valueOf(meLevel))
                .param("peLevel", String.valueOf(peLevel))
                .param("sharingLevel", sharingLevel);
        if (itemID != null) {
            taskOptions.param("itemID", String.valueOf(itemID));
        }
        if (attachedCharacterID != null) {
            taskOptions.param("attachedCharacterID", String.valueOf(attachedCharacterID));
        }
        queue.add(taskOptions);
    }
View Full Code Here

        queue.add(taskOptions);
    }

    public void launch(Long userID, String blueprintTypeName, Long itemID, Integer meLevel, Integer peLevel, Long attachedCharacterID, String sharingLevel) {
        logger.info("Scheduling blueprint add task");
        Queue queue = appEngineServices.getQueue(queueName);
        TaskOptions taskOptions = withUrl(TASK_ADD_BLUEPRINT).param("userID", String.valueOf(userID))
                .param("blueprintTypeName", String.valueOf(blueprintTypeName))
                .param("meLevel", String.valueOf(meLevel))
                .param("peLevel", String.valueOf(peLevel))
                .param("sharingLevel", sharingLevel);
        if (itemID != null) {
            taskOptions.param("itemID", String.valueOf(itemID));
        }
        if (attachedCharacterID != null) {
            taskOptions.param("attachedCharacterID", String.valueOf(attachedCharacterID));
        }
        queue.add(taskOptions);
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.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.