You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2023/02/15 16:48:30 UTC
[camel-karavan] branch main updated: #536: Added Fault Tolerance (#659)
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new cece698f #536: Added Fault Tolerance (#659)
cece698f is described below
commit cece698fa2267f618a1a830d080a1de455836a0a
Author: Rafael Marques <ra...@gmail.com>
AuthorDate: Wed Feb 15 13:48:25 2023 -0300
#536: Added Fault Tolerance (#659)
* Updated the Frontend folder for How to build Karavan, it was wrong with an older folder
* Updated DEV file
* Added Fault Tolerance with Retry and Circuit Breaker)
* the circuit opens if half of the requests (failureRatio = 0.5) of ten consecutive invocations (requestVolumeThreshold=4) fail.
* resolve #536
---
.../org/apache/camel/karavan/service/StatusService.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/service/StatusService.java b/karavan-app/src/main/java/org/apache/camel/karavan/service/StatusService.java
index ed95a39e..c59d1440 100644
--- a/karavan-app/src/main/java/org/apache/camel/karavan/service/StatusService.java
+++ b/karavan-app/src/main/java/org/apache/camel/karavan/service/StatusService.java
@@ -30,6 +30,8 @@ import org.apache.camel.karavan.model.DeploymentStatus;
import org.apache.camel.karavan.model.Environment;
import org.apache.camel.karavan.model.Project;
import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.eclipse.microprofile.faulttolerance.Retry;
+import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
import org.jboss.logging.Logger;
import javax.enterprise.context.ApplicationScoped;
@@ -40,6 +42,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
@ApplicationScoped
@@ -133,10 +136,18 @@ public class StatusService {
}
}
+ @Retry(maxRetries = 6, maxDuration=100)
+ @CircuitBreaker(requestVolumeThreshold = 10, failureRatio = 0.5, delay = 1000)
+ public HttpResponse<Buffer> bufferResult(String url, int timeout) throws InterruptedException, ExecutionException {
+ HttpResponse<Buffer> result = getWebClient().getAbs(url).timeout(timeout).send().subscribeAsCompletionStage().toCompletableFuture().get();
+ return result;
+ }
+
+
private CamelStatus getCamelStatus(String projectId, String url, String runtime) {
// TODO: make it reactive
try {
- HttpResponse<Buffer> result = getWebClient().getAbs(url).timeout(1000).send().subscribeAsCompletionStage().toCompletableFuture().get();
+ HttpResponse<Buffer> result = bufferResult(url, 1000);
if (result.statusCode() == 200) {
JsonObject res = result.bodyAsJsonObject();
if (runtime.equalsIgnoreCase("quarkus")) {