D'autres exemples de AWS SDK sont disponibles dans le référentiel AWS Doc SDK Examples
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation CheckWorkflowStatus
avec un AWS SDK
L'exemple de code suivant montre comment utiliserCheckWorkflowStatus
.
- SDK pour Java 2.x
-
Note
Il y en a plus à ce sujet GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code AWS
. /** * Checks the status of a workflow asynchronously. * * @param jobId the ID of the job to check * @param workflowName the name of the workflow to check * @return a CompletableFuture that resolves to a boolean value indicating whether the workflow has completed * successfully */ public CompletableFuture<GetMatchingJobResponse> checkWorkflowStatusCompleteAsync(String jobId, String workflowName) { GetMatchingJobRequest request = GetMatchingJobRequest.builder() .jobId(jobId) .workflowName(workflowName) .build(); return getResolutionAsyncClient().getMatchingJob(request) .whenComplete((response, exception) -> { if (response != null) { // Process the response and log the job status. logger.info("Job status: " + response.status()); } else { // Ensure exception is not null before accessing its cause. if (exception == null) { throw new CompletionException("An unknown error occurred while checking job status.", null); } Throwable cause = exception.getCause(); if (cause instanceof ResourceNotFoundException) { throw new CompletionException("The requested resource was not found while checking the job status.", cause); } // Wrap other AWS exceptions in a CompletionException. throw new CompletionException("Failed to check job status: " + exception.getMessage(), exception); } }); }
-
Pour plus de détails sur l'API, reportez-vous CheckWorkflowStatusà la section Référence des AWS SDK for Java 2.x API.
-