diff --git a/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.xml b/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.xml deleted file mode 100644 index 6653b5ad7c7..00000000000 --- a/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - pull-queue - pull - - bar@foo.com - bar@foo.com - - - diff --git a/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.yaml b/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.yaml new file mode 100644 index 00000000000..e0c1aadd10b --- /dev/null +++ b/appengine/taskqueue/pull/src/main/webapp/WEB-INF/queue.yaml @@ -0,0 +1,7 @@ +queue: +- name: pull-queue + mode: pull + acl: + - user_email: bar@foo.com # can list, get, lease, delete, and update tasks + - writer_email: user@gmail.com # can insert tasks + - writer_email: bar@foo.com # can insert tasks, in addition to rights granted by being a user_email above diff --git a/taskqueue/pull/README.md b/taskqueue/pull/README.md index 8abbe8f34ed..9837eed8785 100644 --- a/taskqueue/pull/README.md +++ b/taskqueue/pull/README.md @@ -14,26 +14,24 @@ to create one first and then come back and run this sample. reuse an existing project by clicking on it. 1. Note: You will need to enable billing for the project to use Compute Engine. - 1. Click "Overview" in the left-side navigation menu and copy your Project ID - for use in step 3.3 below. 1. Authentication instructions to run the sample (on your local machine or on a Compute Engine VM): * Running the sample locally on your development machine: 1. Install [Google Cloud SDK](https://cloud.google.com/sdk/) 1. Run the following command to authorize the Cloud SDK and configure your project:
gcloud init
- 1. Add your authenticated email account as <user-email> and <writer-email> elements to the queue.xml file of the App Engine app that created the pull queue task you're trying to access. For more details, please see - [Defining Pull Queues](https://cloud.google.com/appengine/docs/java/config/queue#Defining_Pull_Queues) - on the Task Queue configuration page. + 1. Add your authenticated email account as 'user_email' and 'writer_email' elements to the queue.yaml + file of the App Engine app that created the pull queue task you're trying to access. For more details, please see + [Defining Pull Queues](https://cloud.google.com/appengine/docs/java/taskqueue/overview-pull#Java_Defining_pull_queues). * Running the sample on a Google Compute Engine VM using Default Application Credentials: 1. Create a service account and add it to queue.xml 1. In the API Manager > [Credentials](https://pantheon.corp.google.com/apis/credentials) section click "Create credentials" and choose "Service account key". 1. On the "Create service account key" page, select "Compute Engine default service account" from the "Service Account" drop-down menu. Leave the Key type set to JSON and click the "Create" button. 1. Once the service account is created, click the "Manage service accounts" link and copy the "Service account ID" of the "Compute Engine default service account". - 1. Add the "Service account ID" as <user-email> and <writer-email> elements to the queue.xml file of the App Engine app that created the pull queue task you're trying to access. For more details, please see - [Defining Pull Queues](https://cloud.google.com/appengine/docs/java/config/queue#Defining_Pull_Queues) - on the Task Queue configuration page. + 1. Add the "Service account ID" as 'user_email' and 'writer_email' elements to the queue.yaml file of the + App Engine app that created the pull queue task you're trying to access. For more details, please see + [Defining Pull Queues](https://cloud.google.com/appengine/docs/java/taskqueue/overview-pull#Java_Defining_pull_queues). 1. Create a Compute Engine VM Instance. 1. In the [Cloud Console](https://console.cloud.google.com/project) diff --git a/taskqueue/pull/src/main/java/TaskQueueSample.java b/taskqueue/pull/src/main/java/TaskQueueSample.java index a13f03f62b4..5268df52a67 100644 --- a/taskqueue/pull/src/main/java/TaskQueueSample.java +++ b/taskqueue/pull/src/main/java/TaskQueueSample.java @@ -172,8 +172,12 @@ private static Tasks getLeasedTasks(Taskqueue taskQueue) throws IOException { */ private static void processTask(Task task) { byte[] payload = Base64.decodeBase64(task.getPayloadBase64()); - System.out.println("Payload for the task:"); - System.out.println(new String(payload)); + if (payload != null) { + System.out.println("Payload for the task:"); + System.out.println(new String(payload)); + } else { + System.out.println("This task has no payload."); + } } /** * Method that sends a delete request for the specified task object to the taskqueue service.