큐 만들기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
큐를 만듭니다.
더 살펴보기
이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.
코드 샘플
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],[],[],[],null,["# Create a queue\n\nCreates a queue.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Getting started with the Cloud Tasks API (Python)](/walkthroughs/cloudtasks/cloudtasks-python)\n\nCode sample\n-----------\n\n### Java\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html;\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.LocationName.html;\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html;\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.QueueName.html;\n import java.io.IOException;\n\n public class CreateQueue {\n\n public static void main(String[] args) throws IOException {\n // TODO(developer): Replace these variables before running the sample.\n String projectId = \"my-project-id\";\n String locationId = \"us-central1\";\n String queueId = \"my-queue\";\n createQueue(projectId, locationId, queueId);\n }\n\n // Create a queue using the Cloud Tasks client.\n public static void createQueue(String projectId, String locationId, String queueId)\n throws IOException {\n\n // Instantiates a client.\n try (https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html.create()) {\n\n // Construct the fully qualified location.\n String parent = https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.LocationName.html.of(projectId, locationId).toString();\n\n // Construct the fully qualified queue path.\n String queuePath = https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.QueueName.html.of(projectId, locationId, queueId).toString();\n\n // Send create queue request.\n https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html queue = client.createQueue(parent, https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html.newBuilder().setName(queuePath).build());\n\n System.out.println(\"Queue created: \" + queue.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html#com_google_cloud_tasks_v2_Queue_getName__());\n }\n }\n }\n\n### Node.js\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Imports the Google Cloud Tasks library.\n const cloudTasks = require('https://cloud.google.com/nodejs/docs/reference/tasks/latest/overview.html');\n\n // Instantiates a client.\n const client = new cloudTasks.https://cloud.google.com/nodejs/docs/reference/tasks/latest/overview.html();\n\n async function createQueue() {\n // Send create queue request.\n const [response] = await client.createQueue({\n // The fully qualified path to the location where the queue is created\n parent: client.locationPath(project, location),\n queue: {\n // The fully qualified path to the queue\n name: client.queuePath(project, location, queue),\n appEngineHttpQueue: {\n appEngineRoutingOverride: {\n // The App Engine service that will receive the tasks.\n service: 'default',\n },\n },\n },\n });\n console.log(`Created queue ${response.name}`);\n }\n createQueue();\n\n### Python\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import tasks_v2\n\n\n def create_queue(project: str, location: str, queue_id: str) -\u003e tasks_v2.Queue:\n \"\"\"Create a queue.\n Args:\n project: The project ID to create the queue in.\n location: The location to create the queue in.\n queue_id: The ID to use for the new queue.\n\n Returns:\n The newly created queue.\n \"\"\"\n\n # Create a client.\n client = tasks_v2.CloudTasksClient()\n\n # Use the client to send a CreateQueueRequest.\n return client.create_queue(\n tasks_v2.CreateQueueRequest(\n parent=client.common_location_path(project, location),\n queue=tasks_v2.Queue(name=client.queue_path(project, location, queue_id)),\n )\n )\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=cloud_tasks)."]]