There are more AWS SDK examples available in the AWS Doc SDK Examples
Use GetMatchingJob
with an AWS SDK
The following code example shows how to use GetMatchingJob
.
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /** * Asynchronously retrieves a matching job based on the provided job ID and workflow name. * * @param jobId the ID of the job to retrieve * @param workflowName the name of the workflow associated with the job * @return a {@link CompletableFuture} that completes when the job information is available or an exception occurs */ public CompletableFuture<GetMatchingJobResponse> getMatchingJobAsync(String jobId, String workflowName) { GetMatchingJobRequest request = GetMatchingJobRequest.builder() .jobId(jobId) .workflowName(workflowName) .build(); return getResolutionAsyncClient().getMatchingJob(request) .whenComplete((response, exception) -> { if (response != null) { // Successfully fetched the matching job details, log the job status. logger.info("Job status: " + response.status()); logger.info("Job details: " + response.toString()); } else { if (exception == null) { throw new CompletionException("An unknown error occurred while fetching the matching job.", null); } Throwable cause = exception.getCause(); if (cause instanceof ResourceNotFoundException) { throw new CompletionException("The requested job could not be found.", cause); } // Wrap other exceptions in a CompletionException with the message. throw new CompletionException("Error fetching matching job: " + exception.getMessage(), exception); } }); }
-
For API details, see GetMatchingJob in AWS SDK for Java 2.x API Reference.
-