Queue (Google App Engine API for Java)


Interface Queue

  • public interface Queue
    Queue is used to manage a task queue.

    Implementations of this interface must be threadsafe.

    Queues are transactional. If a datastore transaction is in progress when add() or add(TaskOptions) is invoked, the task will only be added to the queue if the datastore transaction successfully commits. If you want to add a task to a queue and have that operation succeed or fail independently of an existing datastore transaction you can invoke add(Transaction, TaskOptions) with a null transaction argument. Note that while the addition of the task to the queue can participate in an existing transaction, the execution of the task cannot participate in this transaction. In other words, when the transaction commits you are guaranteed that your task will be added and run, not that your task executed successfully.

    Queues may be configured in either push or pull mode, but they share the same interface. However, only tasks with TaskOptions.Method.PULL may be added to pull queues. The tasks in push queues must be added with one of the other available methods.

    Pull mode queues do not automatically deliver tasks to the application. The application is required to call leaseTasks to acquire a lease on the task and process them explicitly. Attempting to call leaseTasks on a push queue causes a InvalidQueueModeException to be thrown. When the task processing has finished processing a task that is leased, it should call deleteTask(String). If deleteTask is not called before the lease expires, the task will again be available for lease.

    Queue mode can be switched between push and pull. When switching from push to pull, tasks will stay in the task queue and are available for lease, but url and headers information will be ignored when returning the tasks. When switching from pull to push, existing tasks will remain in the queue but will fail on auto-execution because they lack a url. If the queue mode is once again changed to pull, these tasks will eventually be available for lease.