Skip to content

Commit 9e9120a

Browse files
authored
Update comments in Task samples (#1418)
1 parent 0730123 commit 9e9120a

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

tasks/README.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# Google Cloud Tasks App Engine Queue Samples
1+
# Google Cloud Tasks Samples
22

3-
Sample command-line program for interacting with the Cloud Tasks API
4-
using App Engine queues.
5-
6-
App Engine queues push tasks to an App Engine HTTP target. This directory
7-
contains both the App Engine app to deploy, as well as the snippets to run
8-
locally to push tasks to it, which could also be called on App Engine.
3+
This sample demonstrates using the Cloud Tasks client library.
94

105
`CreateHTTPTask.java` constructs a task with an HTTP target and pushes it
116
to your queue.
127

13-
`CreateHTTPTask.java` constructs a task with an HTTP target and OIDC token and pushes it
14-
to your queue.
8+
`CreateHTTPTask.java` constructs a task with an HTTP target and OIDC token and
9+
pushes it to your queue.
1510

1611
## Initial Setup
1712

@@ -27,18 +22,7 @@ to your queue.
2722
To create a queue using the Cloud SDK, use the following gcloud command:
2823

2924
```
30-
gcloud beta tasks queues create-app-engine-queue my-queue
31-
```
32-
33-
Note: A newly created queue will route to the default App Engine service and
34-
version unless configured to do otherwise.
35-
36-
## Deploying the App Engine app
37-
[Using Maven and the App Engine Plugin](https://cloud.google.com/appengine/docs/flexible/java/using-maven)
38-
& [Maven Plugin Goals and Parameters](https://cloud.google.com/appengine/docs/flexible/java/maven-reference)
39-
40-
```
41-
mvn appengine:deploy
25+
gcloud beta tasks queues create <QUEUE_NAME>
4226
```
4327

4428
## Run the Sample Using the Command Line
@@ -61,7 +45,7 @@ export QUEUE_ID=my-queue
6145
And finally the location ID, which can be discovered with
6246
`gcloud beta tasks queues describe $QUEUE_ID`, with the location embedded in
6347
the "name" value (for instance, if the name is
64-
"projects/my-project/locations/us-central1/queues/my-appengine-queue", then the
48+
"projects/my-project/locations/us-central1/queues/my-queue", then the
6549
location is "us-central1").
6650

6751
```
@@ -71,24 +55,32 @@ export LOCATION_ID=<YOUR_ZONE>
7155
### Using HTTP Push Queues
7256

7357
Set an environment variable for the endpoint to your task handler. This is an
74-
example url to send requests to the App Engine task handler:
58+
example url:
7559
```
76-
export URL=https://${PROJECT_ID}.appspot.com/tasks/create
60+
export URL=https://example.com/taskshandler
7761
```
7862

79-
Running the sample will create a task and send the task to the specific URL
80-
endpoint, with a payload specified:
63+
Running the sample will create a task and add it to your queue. As the queue
64+
processes each task, it will send the task to the specific URL endpoint:
8165

8266
```
8367
mvn exec:java@HttpTask"
8468
```
8569

86-
### Using HTTP Targets with Authentication Headers
70+
### Using HTTP Targets with Authentication Tokens
71+
72+
Your Cloud Tasks [service account][sa],
73+
(service-<project-number>@gcp-sa-cloudtasks.iam.gserviceaccount.com), must
74+
have the role of: `Service Account Token Creator` to generate a tokens.
8775

88-
In `CreateHttpTaskWithToken.java`, add your service account email in place of
89-
`<SERVICE_ACCOUNT_EMAIL>` to authenticate the OIDC token.
76+
Create or use an existing [service account][sa] to replace `<SERVICE_ACCOUNT_EMAIL>`
77+
in `CreateHttpTaskWithToken.java`. This service account will be used to
78+
authenticate the OIDC token.
9079

9180
Running the sample with command:
9281
```
9382
mvn exec:java@WithToken"
9483
```
84+
85+
86+
[sa]: https://cloud.google.com/iam/docs/service-accounts

tasks/src/main/java/com/example/task/CreateHttpTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void main(String[] args) throws Exception {
3939
// projectId = "my-project-id";
4040
// queueName = "my-queue";
4141
// location = "us-central1";
42-
// url = "https://example.com/hellohandler";
42+
// url = "https://example.com/taskhandler";
4343
String payload = "hello";
4444

4545
// Construct the fully qualified queue name.

tasks/src/main/java/com/example/task/CreateHttpTaskWithToken.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void main(String[] args) throws Exception {
4040
// projectId = "my-project-id";
4141
// queueName = "my-appengine-queue";
4242
// location = "us-central1";
43-
// url = "https://example.com/tasks/create";
43+
// url = "https://example.com/taskhandler";
4444
String payload = "hello";
4545

4646
// Construct the fully qualified queue name.

0 commit comments

Comments
 (0)