文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeleteJobQueue
搭配 AWS SDK 或 CLI 使用
下列程式碼範例示範如何使用 DeleteJobQueue
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- CLI
-
- AWS CLI
-
刪除任務佇列
此範例會刪除 GPGPU 任務佇列。
命令:
aws batch delete-job-queue --job-queue GPGPU
- Java
-
- SDK for Java 2.x
-
/**
* Deletes a Batch job queue asynchronously.
*
* @param jobQueueArn The Amazon Resource Name (ARN) of the job queue to delete.
* @return A CompletableFuture that represents the asynchronous deletion of the job queue.
* The future completes when the job queue has been successfully deleted or if an error occurs.
* If successful, the future will be completed with a {@code Void} value.
* If an error occurs, the future will be completed exceptionally with the thrown exception.
*/
public CompletableFuture<Void> deleteJobQueueAsync(String jobQueueArn) {
DeleteJobQueueRequest deleteRequest = DeleteJobQueueRequest.builder()
.jobQueue(jobQueueArn)
.build();
CompletableFuture<DeleteJobQueueResponse> responseFuture = getAsyncClient().deleteJobQueue(deleteRequest);
return responseFuture.whenComplete((deleteResponse, ex) -> {
if (ex != null) {
throw new RuntimeException("Failed to delete job queue: " + ex.getMessage(), ex);
}
}).thenApply(deleteResponse -> null);
}