AWS 문서 AWS SDK SDK 예제 GitHub 리포지토리에 더 많은 예제가 있습니다.
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
SubmitJob
AWS SDKOR와 함께 사용 CLI
다음 코드 예제는 SubmitJob
의 사용 방법을 보여 줍니다.
작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.
- CLI
-
- AWS CLI
-
작업을 제출하려면
이 예제는 example이라는 간단한 컨테이너 작업을 HighPriority 작업 대기열에 제출합니다.
명령:
aws batch submit-job --job-name example
--job-queue HighPriority
--job-definition sleep60
출력:
{
"jobName": "example",
"jobId": "876da822-4198-45f2-a252-6cea32512ea8"
}
- Java
-
- SDK자바 2.x의 경우
-
/**
* Submits a job asynchronously to the AWS Batch service.
*
* @param jobDefinitionName the name of the job definition to use
* @param jobQueueName the name of the job queue to submit the job to
* @param jobARN the Amazon Resource Name (ARN) of the job definition
* @return a CompletableFuture that, when completed, contains the job ID of the submitted job
*/
public CompletableFuture<String> submitJobAsync(String jobDefinitionName, String jobQueueName, String jobARN) {
SubmitJobRequest jobRequest = SubmitJobRequest.builder()
.jobDefinition(jobARN)
.jobName(jobDefinitionName)
.jobQueue(jobQueueName)
.build();
CompletableFuture<SubmitJobResponse> responseFuture = getAsyncClient().submitJob(jobRequest);
responseFuture.whenComplete((response, ex) -> {
if (ex != null) {
throw new RuntimeException("Unexpected error occurred: " + ex.getMessage(), ex);
}
});
return responseFuture.thenApply(SubmitJobResponse::jobId);
}