Package com.google.appengine.api.taskqueue

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


    public void testPullWithGroupTag() throws Exception {
        final Queue queue = QueueFactory.getQueue("pull-queue");
        String tag = "testPullWithGroupTag" + "_" + System.currentTimeMillis();

        long currentTime = System.currentTimeMillis();
        TaskHandle th1 = queue.add(withMethod(PULL).tag(tag).payload("foobar").etaMillis(currentTime));
        TaskHandle th2 = queue.add(withMethod(PULL).tag(tag + "qwerty").payload("foofoo").etaMillis(currentTime + 1000));
        TaskHandle th3 = queue.add(withMethod(PULL).tag(tag).payload("foofoo").etaMillis(currentTime + 2000));
        sync();

        try {
            LeaseOptions options = new LeaseOptions(LeaseOptions.Builder
                .withLeasePeriod(1000L, TimeUnit.SECONDS))
View Full Code Here


    }

    @Test
    public void testLeaseTasksOnlyReturnsSpecifiedNumberOfTasks() {
        Queue queue = QueueFactory.getQueue("pull-queue");
        TaskHandle th1 = queue.add(withMethod(PULL));
        TaskHandle th2 = queue.add(withMethod(PULL));
        sync(2000);
        try {
            int countLimit = 1;
            List<TaskHandle> handles = waitOnFuture(queue.leaseTasksAsync(10, TimeUnit.SECONDS, countLimit));
            assertEquals(countLimit, handles.size());
View Full Code Here

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

    }

    @Test
    public void testTaskHandleContainsAutoGeneratedTaskNameWhenTaskNameNotDefinedInTaskOptions() throws Exception {
        Queue queue = QueueFactory.getDefaultQueue();
        TaskHandle handle = waitOnFuture(queue.addAsync());
        assertNotNull(handle.getName());
    }
View Full Code Here

        }
       
        URL uri = new URL(url);
        String path = uri.getPath();   
        Queue queue = QueueFactory.getDefaultQueue();
        TaskHandle task = queue.add(withUrl(path)
            .payload(request.toString())
            .countdownMillis(delay));
       
        // store task information
        DateTime timestamp = DateTime.now().plus(delay);
        GaeTask storedTask = new GaeTask(task.getName(),
            agentId, timestamp.toString());
        ObjectDatastore datastore = new AnnotationObjectDatastore();
        datastore.store(storedTask);
       
        return task.getName();     
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      // TODO: throw error?
View Full Code Here

        Date endDate = new Date();
        Queue queue = TaskUtils.getQueue(FileMoveDeleter.class);
        TaskOptions options = TaskUtils.newTaskOptions(FileMoveDeleter.class)
            .param("owner", KeyFactory.keyToString(user.getKey()))
            .param(pEND_DATE, String.valueOf(endDate.getTime()));
        TaskHandle handle = queue.add(options);
        Logger.info("Enqueued delete task. User key: %s End date: %s", user.getKey(), endDate);
        return handle;
    }
View Full Code Here

        }
       
        URL uri = new URL(url);
        String path = uri.getPath();   
        Queue queue = QueueFactory.getDefaultQueue();
        TaskHandle task = queue.add(withUrl(path)
            .payload(request.toString())
            .countdownMillis(delay));
       
        // store task information
        DateTime timestamp = DateTime.now().plus(delay);
        GaeTask storedTask = new GaeTask(task.getName(),
            agentId, timestamp.toString());
        ObjectDatastore datastore = new AnnotationObjectDatastore();
        datastore.store(storedTask);
       
        return task.getName();     
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      // TODO: throw error?
View Full Code Here

        if (url != null){
          URL uri = url.toURL();
          path = uri.getPath();
        }
        Queue queue = QueueFactory.getDefaultQueue();
        TaskHandle task = queue.add(withUrl(path)
            .payload(request.toString())
            .countdownMillis(delay));
       
        // store task information
        DateTime timestamp = DateTime.now().plus(delay);
        GaeTask storedTask = new GaeTask(task.getName(),
            agentId, timestamp.toString());
        ObjectDatastore datastore = new AnnotationObjectDatastore();
        datastore.store(storedTask);
       
        return task.getName();     
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      // TODO: throw error?
View Full Code Here

TOP

Related Classes of com.google.appengine.api.taskqueue.TaskHandle

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.