GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-docs-samples/cloud-tasks at master · aalexand/java-docs-samples

Expand file tree

/

cloud-tasks

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

cloud-tasks

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

README.md

Outline

Google Cloud Tasks Pull Queue Samples

Open in Cloud Shell

Sample command-line program for interacting with the Google Cloud Tasks API using pull queues.

Pull queues let you add tasks to a queue, then programatically remove and interact with them. Tasks can be added or processed in any environment, such as on Google App Engine or Google Compute Engine.

PullQueue.java is a simple command-line program to demonstrate listing queues, creating tasks, and pulling and acknowledging tasks.

Initial Setup

  • Set up a Google Cloud Project and enable billing.
  • Enable the Cloud Tasks API.
  • Download and install the Cloud SDK.
  • Download and install Maven.

Creating a queue

To create a queue using the Cloud SDK, use the following gcloud command:

gcloud alpha tasks queues create-pull-queue my-pull-queue

In this example, the queue will be named my-pull-queue.

Running the Samples

From the project folder, build your project with:

mvn clean assembly:single

Optionally, you can set up your settings as environment variables:

export PROJECT_ID=<YOUR_PROJECT_ID>
export LOCATION_ID=<YOUR_ZONE>
export QUEUE_ID=<YOUR_QUEUE_NAME>

Next, create a task for a queue:

java -cp target/cloudtasks-1.0.0-jar-with-dependencies.jar \
    com.example.PullQueue create-task --project=$PROJECT_ID --location=$LOCATION_ID --queue=$QUEUE_ID

Finally, pull and acknowledge a task:

java -cp target/cloudtasks-1.0.0-jar-with-dependencies.jar \
    com.example.PullQueue pull-and-ack-task --project=$PROJECT_ID --location=$LOCATION_ID --queue=$QUEUE_ID

Note that usually, there would be a processing step in between pulling a task and acknowledging it.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.