이 페이지에서는 작업을 만들어 push 큐에 추가하는 방법에 대해 설명합니다. 태스크를 처리하려면 새 태스크 객체를 만들어 큐에 추가해야 합니다. 태스크를 처리하는 서비스와 핸들러를 명시적으로 지정하고 필요에 따라 태스크별 데이터를 핸들러에 함께 전달할 수 있습니다. 태스크를 실행할 시간을 예약하거나 태스크가 실패할 경우 재시도할 횟수를 제한하는 등 태스크의 구성을 세부적으로 조정할 수도 있습니다.
새 태스크 만들기
작업자 서비스 지정
큐에서 태스크를 꺼내면 태스크 큐 서비스가 작업자 서비스로 해당 태스크를 전송합니다. 모든 태스크에는 최종적으로 태스크를 수행할 서비스와 핸들러를 결정하는 target과 url이 있습니다.
target
target은 태스크를 수행하기 위해 HTTP 요청을 수신할 서비스를 지정합니다. 서비스/버전/인스턴스를 표준 형식 중 하나로 지정하는 문자열로서 가장 일반적으로 사용되는 형식은 다음과 같습니다.
service
version.service
instance.version.service
target 문자열은 앱의 도메인 이름 앞에 추가됩니다. 다음 세 가지 방법으로 태스크의 target을 설정할 수 있습니다.
태스크를 생성할 때 대상을 선언합니다.
queue-blue의 정의에서처럼 queue.yaml에서 큐를 정의할 때 target 지시문을 포함합니다.
target이 있는 큐에 추가되는 모든 태스크는 태스크 생성 시점에 다른 target이 할당되었더라도 큐의 target을 사용합니다.
앞의 두 가지 방법 중 하나로 target을 지정하지 않으면 태스크를 큐에 추가한 서비스 버전이 태스크의 target이 됩니다.
기본 서비스와 버전에서 이 방식으로 태스크를 큐에 추가한 경우, 태스크가 실행되기 전에 기본 버전이 변경되면 새 기본 버전에서 태스크가 실행됩니다.
url
url은 target 서비스의 핸들러 중에서 태스크를 수행할 핸들러 하나를 선택합니다.
url은 target 서비스의 핸들러 URL 패턴 중 하나와 일치해야 합니다. 태스크에 지정된 메서드가 GET 또는 PULL인 경우 url에 쿼리 매개변수가 포함될 수 있습니다. url을 지정하지 않으면 기본 URL인 /_ah/queue/[QUEUE_NAME]이 사용되며, 여기서 [QUEUE_NAME]은 태스크의 큐 이름입니다.
핸들러에 데이터 전달
태스크에 지정된 메서드가 GET 또는 PULL인 경우에만 태스크의 URL에 포함되는 쿼리 매개변수로 데이터를 핸들러에 전달할 수 있습니다.
태스크 이름 지정
새 태스크를 만들면 기본적으로 App Engine이 태스크에 고유한 이름을 할당합니다. 그러나 name 파라미터를 사용하면 태스크 이름을 직접 할당할 수 있습니다. 태스크 이름을 직접 할당하면 명명된 태스크가 중복되지 않는다는 이점이 있습니다. 즉, 태스크 이름을 사용하면 한 태스크가 한 번만 추가됨을 보장할 수 있습니다. 중복 제거는 태스크 완료 또는 삭제 후 9일 동안 유지됩니다.
중복 제거 로직은 상당한 성능 오버헤드를 유발하며, 이에 따라 지연 시간이 증가하고 명명된 태스크와 관련하여 오류율이 상승할 수 있습니다. 태스크 이름이 타임스탬프처럼 순차적인 경우에는 이러한 비용이 대폭 증가할 수 있습니다. 따라서 이름을 직접 할당할 때는 태스크 이름에 콘텐츠의 해시와 같이 고르게 분산되는 프리픽스를 사용하는 것이 좋습니다.
태스크 이름을 직접 할당하는 경우 이름의 최대 길이는 500자이며 대문자, 소문자, 숫자, 밑줄, 하이픈을 포함할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eTasks are created as objects and placed on queues for processing, with the option to specify the service and handler responsible for their execution.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etarget\u003c/code\u003e parameter designates the specific service, version, or instance that will process the task, and it can be set during task creation, within the queue definition, or default to the service enqueuing the task.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eurl\u003c/code\u003e parameter within a task specifies the handler in the target service that will process it and can include query parameters for \u003ccode\u003eGET\u003c/code\u003e or \u003ccode\u003ePULL\u003c/code\u003e methods, defaulting to \u003ccode\u003e/_ah/queue/[QUEUE_NAME]\u003c/code\u003e if not specified.\u003c/p\u003e\n"],["\u003cp\u003eWhile App Engine assigns unique names by default, you can provide custom task names to enable de-duplication, ensuring a task is only added once, although this introduces performance overhead and latency.\u003c/p\u003e\n"],["\u003cp\u003eData can be passed to the handler via query parameters within the task's URL if the method is \u003ccode\u003eGET\u003c/code\u003e or \u003ccode\u003ePULL\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Create Push Tasks\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nGo Java PHP Python\n\nThis page describes how to create tasks and place them in push queues. When you\nwant to process a task, you must create a new task object and place it on a\nqueue. You can explicitly specify the service and handler that process the task,\nand optionally pass task-specific data along to the handler. You can also\nfine-tune the configuration for the task, like scheduling a time in the future\nwhen it should be executed or limiting the number of times you want the task to\nbe retried if it fails.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n|\n| /services/access). If you are updating to the App Engine runtime, refer to the [Upgrade to second-generation runtimes]() page to learn about your migration options for legacy bundled services.\n\nCreating a new task\n-------------------\n\nSpecifying the worker service\n-----------------------------\n\nWhen a task is popped off its queue, the Task Queue service sends it on\nto a worker service. Every task has a *target* and a *url*, which determine\nwhat service and handler will ultimately perform the task.\n\n### `target`\n\nThe target specifies the service that will receive the HTTP request to\nperform the task. It is a string that specifies a service/version/instance in\nany one of the [canonical forms](/appengine/docs/standard/how-requests-are-routed#routing_via_url). The most often-used forms are: \n\n service\n version.service\n instance.version.service\n\nThe target string is prepended to the domain name of your app. There are three\nways to set the target for a task:\n\n- Declare the target when you construct the task.\n\n\n- Include a `target` directive when you define a queue in the\n `queue.yaml`, as in the [definition](/appengine/docs/standard/services/taskqueue/push/creating-push-queues) of `queue-blue`.\n All tasks added to a queue with a `target` will use that target, even if\n a different target was assigned to the task at construction time.\n\n- If no target is specified according to either of the previous two methods,\n then the task's target is the version of the service that enqueues it.\n Note that if you enqueue a task from the default service and version in\n this manner, and the default version changes before the task executes, it\n will run in the new default version.\n\n### `url`\n\nThe `url` selects one of the handlers in the target service, which will\nperform the task.\n\nThe `url` should match one of the handler URL patterns in the target\nservice. The `url` can include query parameters if the method specified in the task is\n`GET` or `PULL`. If no `url` is specified the default URL\n`/_ah/queue/[QUEUE_NAME]` is used, where `[QUEUE_NAME]` is the name of\nthe task's queue.\n\nPassing data to the handler\n---------------------------\n\nYou can pass data to the handler as query parameters in the task's URL, but\nonly if the method specified in the task is `GET` or `PULL`.\n\nNaming a task\n-------------\n\nWhen you create a new task, App Engine assigns the task a unique name by\ndefault. However, you can assign your own name to a task by using the `name`\nparameter. An advantage of assigning your own task names is that named tasks are\nde-duplicated, which means you can use task names to\nguarantee\nthat a task is only added once. De-duplication continues for 9 days after the\ntask is completed or deleted.\n\nNote that de-duplication logic introduces significant performance overhead,\nresulting in increased latencies and potentially increased error rates\nassociated with named tasks. These costs can be magnified significantly if task\nnames are sequential, such as with timestamps. So, if you assign your own names,\nwe recommend using a well-distributed prefix for task names, such as a hash of\nthe contents.\n\nIf you assign your own names to tasks, note that the maximum name length is 500\ncharacters, and the name can contain uppercase and lowercase letters, numbers\nunderscores, and hyphens.\n\nWhat's next\n-----------\n\n- Learn how to [create task\n handlers](/appengine/docs/standard/services/taskqueue/push/creating-handlers)."]]