Java 8 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Java 8 アプリケーションをデプロイできなくなります。既存の Java 8 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Java に移行することをおすすめします。
Java で pull キューを使用する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、App Engine スタンダード環境での pull キューの概要について説明します。
push キューでは、タスクはキューの構成に基づいてワーカー サービスに配信されます。pull キューでは、ワーカー サービスがキューに対してタスクに関する「問い合わせ」を行う必要があります。キューは、一定の期間タスクを処理する権限をワーカーに許可します。このプロセスをリースといいます。

pull キューを使用すると、関連するタスクをタグでグループ化し、特定のタグを持つ複数のタスクを一度に pull するようにワーカーを構成することもできます。このプロセスは「バッチ処理」と呼ばれます。
リースが期限切れになる前にワーカーがタスクを完了できない場合、リースを更新することも、別のワーカーが取得できるように解放することもできます。タスクに関連付けられた処理が完了したら、ワーカーはそのタスクを削除する必要があります。
pull キューを使用する場合は、push キューで自動的に実行される関数をコード側で処理する必要があります。
- ワーカーのスケーリング
- コードは、処理量に応じてワーカーの数をスケールする必要があります。コード側でスケーリングを行わないと、処理するタスクがない場合に、コンピューティング リソースを浪費するリスクがあります。処理するタスクが多すぎる場合も、レイテンシが発生するリスクがあります。
- タスクの削除
- 処理が終了したら、コードで明示的にタスクを削除する必要があります。push キューでは、App Engine でタスクが自動的に削除されます。処理の終わった pull キューのタスクをワーカーが削除しないと、別のワーカーがそのタスクを再度処理してしまいます。タスクがべき等でない場合は、コンピューティング リソースを浪費してエラーが発生するリスクがあります。
App Engine スタンダード環境で pull キューを作成するには、queue.xml
という名前の構成ファイルでプロパティを設定します。
pull キューのワークフロー
pull キューからタスクを処理するワーカーは、App Engine スタンダード環境で実行されるサービス内で定義する必要があります。
ワークフローは次のとおりです。
queue.xml
を使用して pull キューを作成します。
- タスクを作成してキューに追加します。
- 事前に作成しておいたワーカーが、TaskQueue を使用してタスクをリースします。
- App Engine が、リース応答でワーカーにタスクデータを送信します。
- ワーカーがタスクを処理します。リースの期限までにタスクを実行できなかった場合、ワーカーはリース期間を変更できます。リースが期限切れになると、そのタスクは別のワーカーにリースできるようになります。
- タスクの処理が正常に完了したら、ワーカーがそのタスクを削除します。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","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\u003ePull queues in the App Engine standard environment require worker services to actively request tasks, unlike push queues where tasks are automatically delivered.\u003c/p\u003e\n"],["\u003cp\u003eWorkers using pull queues can utilize task grouping with tags and batching to handle related tasks efficiently.\u003c/p\u003e\n"],["\u003cp\u003ePull queue workers must manage scaling and explicitly delete tasks after processing to prevent resource waste and errors.\u003c/p\u003e\n"],["\u003cp\u003eThe pull queue workflow involves creating queues and tasks, leasing tasks to workers, processing tasks, and then deleting completed tasks.\u003c/p\u003e\n"],["\u003cp\u003ePull queues are configured using a \u003ccode\u003equeue.xml\u003c/code\u003e file within the App Engine standard environment.\u003c/p\u003e\n"]]],[],null,["# Using Pull Queues in Java\n\nThis page provides an overview of pull queues in the App Engine\nstandard environment.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| java-gen2\n|\n| /services/access). If you are updating to the App Engine Java 11/17 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/java-differences) to learn about your migration options for legacy bundled services.\n\nIn *push* queues tasks are delivered to a worker service\nbased on the queue's configuration. In *pull* queues the worker service must *ask*\nthe queue for tasks. The queue responds by allowing that worker unique access\nto process the task for a specified period of time, which is called a *lease*.\n\nUsing pull queues, you can also group related tasks using tags and then configure your\nworker to pull multiple tasks with a certain tag all at once. This process is\ncalled *batching*.\n\nIf a worker cannot process a task before its lease expires, it can either renew the\nlease or let it expire, at which point another worker can acquire it. Once the\nwork associated with a task is complete, the worker must delete it.\n\nUsing pull queues requires your code to handle some functions that are automated\nin push queues:\n\nScaling your workers\n: Your code needs to scale the number of workers based on\n processing volume. If your code does not handle scaling, you risk\n wasting computing resources if there are no tasks to process; you also risk\n latency if you have too many tasks to process.\n\nDeleting the tasks\n: Your code also needs to explicitly delete tasks after processing.\n In push queues, App Engine deletes the tasks for you. If your worker does\n not delete pull queue tasks after processing, another worker will re-process\n the task. This wastes computing resources and risks errors if tasks are\n not [idempotent](https://wikipedia.org/wiki/Idempotence).\n\nPull queues in the App Engine standard environment are created by setting a property in a\nconfiguration file called `queue.xml`.\n\nPull queue workflow\n-------------------\n\nWorkers that process tasks from pull queues must be defined within a service that runs\nin the App Engine standard environment.\n\nThe workflow is as follows:\n\n1. You [create a pull queue](/appengine/docs/legacy/standard/java/taskqueue/pull/creating-pull-queues), using `queue.xml`.\n2. You [create tasks](/appengine/docs/legacy/standard/java/taskqueue/pull/creating-tasks) and add them to the queue.\n3. The worker you have created [leases the task](/appengine/docs/legacy/standard/java/taskqueue/pull/leasing-pull-tasks), using [TaskQueue.](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/taskqueue/package-summary)\n4. App Engine sends task data to the worker in the lease response.\n5. The worker processes the task. If the task fails to execute before the lease expires, the worker can modify the lease duration. If the lease expires, the task will be available to be leased to another worker.\n6. After a task is processed successfully, the [worker deletes it](/appengine/docs/legacy/standard/java/taskqueue/pull/leasing-pull-tasks#deleting-tasks).\n\nWhat's next\n-----------\n\n- Learn how to [create pull queues](/appengine/docs/legacy/standard/java/taskqueue/pull/creating-pull-queues)."]]