james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [01/14] james-project git commit: JAMES-2544 Use Feign retry mechanism to retry calls on RabbitMQ management API
Date Wed, 10 Oct 2018 08:48:14 GMT
Repository: james-project
Updated Branches:
  refs/heads/master eec12864d -> 34f102990


JAMES-2544 Use Feign retry mechanism to retry calls on RabbitMQ management API


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/01352919
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/01352919
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/01352919

Branch: refs/heads/master
Commit: 01352919615cb49d70934e03759e885cb69dc7ad
Parents: eec1286
Author: Benoit Tellier <btellier@linagora.com>
Authored: Wed Oct 10 09:12:16 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Oct 10 09:15:24 2018 +0700

----------------------------------------------------------------------
 .../james/queue/rabbitmq/RabbitMQManagementApi.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/01352919/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java
index 8d39b24..cbeea3a 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQManagementApi.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.queue.rabbitmq;
 
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Stream;
 
@@ -30,13 +31,23 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import feign.Feign;
 import feign.Logger;
 import feign.RequestLine;
+import feign.RetryableException;
+import feign.Retryer;
 import feign.auth.BasicAuthRequestInterceptor;
+import feign.codec.ErrorDecoder;
 import feign.jackson.JacksonDecoder;
 import feign.jackson.JacksonEncoder;
 import feign.slf4j.Slf4jLogger;
 
 class RabbitMQManagementApi {
 
+    private static final ErrorDecoder RETRY_500 = (methodKey, response) -> {
+        if (response.status() == 500) {
+            throw new RetryableException("Error encountered, scheduling retry", response.request().httpMethod(),
new Date());
+        }
+        throw new RuntimeException("Non recoverable exception status: " + response.status());
+    };
+
     public interface Api {
 
         class MessageQueue {
@@ -58,6 +69,8 @@ class RabbitMQManagementApi {
             .logLevel(Logger.Level.FULL)
             .encoder(new JacksonEncoder())
             .decoder(new JacksonDecoder())
+            .retryer(new Retryer.Default())
+            .errorDecoder(RETRY_500)
             .target(Api.class, configuration.getManagementUri().toString());
 
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message