samples/createQueue.js
async function createQueue(
  project = 'my-project-id', // Your GCP Project id
  queue = 'my-appengine-queue', // Name of the Queue to create
  location = 'us-central1' // The GCP region in which to create the queue
) {
  // Imports the Google Cloud Tasks library.
  const cloudTasks = require('@google-cloud/tasks');

  // Instantiates a client.
  const client = new cloudTasks.CloudTasksClient();

  // Send create queue request.
  const [response] = await client.createQueue({
    // The fully qualified path to the location where the queue is created
    parent: client.locationPath(project, location),
    queue: {
      // The fully qualified path to the queue
      name: client.queuePath(project, location, queue),
      appEngineHttpQueue: {
        appEngineRoutingOverride: {
          // The App Engine service that will receive the tasks.
          service: 'default',
        },
      },
    },
  });
  console.log(`Created queue ${response.name}`);
}
async function createQueue(
  project = 'my-project-id', // Your GCP Project id
  queue = 'my-appengine-queue', // Name of the Queue to create
  location = 'us-central1' // The GCP region in which to create the queue
) {
  // Imports the Google Cloud Tasks library.
  const cloudTasks = require('@google-cloud/tasks');

  // Instantiates a client.
  const client = new cloudTasks.CloudTasksClient();

  // Send create queue request.
  const [response] = await client.createQueue({
    // The fully qualified path to the location where the queue is created
    parent: client.locationPath(project, location),
    queue: {
      // The fully qualified path to the queue
      name: client.queuePath(project, location, queue),
      appEngineHttpQueue: {
        appEngineRoutingOverride: {
          // The App Engine service that will receive the tasks.
          service: 'default',
        },
      },
    },
  });
  console.log(`Created queue ${response.name}`);
}
async function createQueue ( project = 'my-project-id' , // Your GCP Project id queue = 'my-appengine-queue' , // Name of the Queue to create location = 'us-central1' // The GCP region in which to create the queue ) { // Imports the Google Cloud Tasks library. const cloudTasks = require ( '@google-cloud/tasks' ) ; // Instantiates a client. const client = new cloudTasks . CloudTasksClient ( ) ; // Send create queue request. const [ response ] = await client . createQueue ( { // The fully qualified path to the location where the queue is created parent : client . locationPath ( project , location ) , queue : { // The fully qualified path to the queue name : client . queuePath ( project , location , queue ) , appEngineHttpQueue : { appEngineRoutingOverride : { // The App Engine service that will receive the tasks. service : 'default' , } , } , } , } ) ; console . log ( ` ${ response . name } ` ) ; }
Create a new Task Queue
Create a new Task Queue