This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch samples-for-2.7.0-SNAPSHOT
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-samples.git


The following commit(s) were added to refs/heads/samples-for-2.7.0-SNAPSHOT by 
this push:
     new 1b85eb6  resilience4j dubbo sample
1b85eb6 is described below

commit 1b85eb6f974dcaa9b8246600dc091cd37e34d3e9
Author: cvictory <shenglic...@gmail.com>
AuthorDate: Wed Jan 2 15:10:20 2019 +0800

    resilience4j dubbo sample
---
 .../apache/dubbo/samples/api/GreetingsService.java |   6 +-
 .../dubbo/samples/governance/AsyncConsumer.java    |  23 ++--
 .../governance/filter/AsyncPostprocessFilter.java  |   9 +-
 .../main/resources/spring/dubbo-demo-consumer.xml  |   2 +-
 .../main/resources/spring/dubbo-demo-provider.xml  |   4 +-
 .../Resilience4jAnnotationConsumer.java            |   2 +-
 .../resilience4j/action/AnnotationAction.java      |  39 ++++--
 .../filter/Resilience4jCircuitBreakerFilter.java   |  39 +++++-
 .../filter/Resilience4jRateLimiterFilter.java      |  13 +-
 .../resilience4j/impl/AnnotationServiceImpl.java   |   2 +-
 .../impl/CircuitBreakerServiceImpl.java            |  14 ++-
 .../resilience4j/impl/RateLimiterServiceImpl.java  |   2 +-
 .../resources/spring/dubbo-consumer.properties     |   3 +-
 .../resources/spring/dubbo-provider.properties     |   2 +-
 .../dubbo-samples-resilience4j-springboot2/pom.xml |  95 ++++++++++++++
 .../Resilience4jBootAnnotationConsumer.java        |  58 ---------
 .../Resilience4jBootAnnotationProvider.java        |  61 ---------
 .../EmbeddedZooKeeper.java                         |   2 +-
 .../api/AnnotationService.java                     |   2 +-
 .../api/CircuitBreakerService.java}                |  10 +-
 .../api/RateLimiterService.java}                   |  10 +-
 .../Resilience4jBootConsumerApplication.java       |  57 +++++++++
 .../consumer}/action/AnnotationAction.java         |  10 +-
 .../action/CircuitBreakMethodWrapper.java}         |  28 ++---
 .../consumer/action/CircuitBreakTypeWrapper.java}  |  28 ++---
 .../consumer/action/CircuitBreakerAction.java      | 138 +++++++++++++++++++++
 .../consumer/action/RateLimiterAction.java         |  75 +++++++++++
 .../consumer/controller/TestController.java        | 103 +++++++++++++++
 .../provider/DubbConfiguration.java}               |  15 ++-
 .../Resilience4jBootProviderApplication.java       |  67 ++++++++++
 .../provider}/impl/AnnotationServiceImpl.java      |  10 +-
 .../provider}/impl/CircuitBreakerServiceImpl.java  |  18 ++-
 .../provider}/impl/RateLimiterServiceImpl.java     |   8 +-
 ...onsumer.properties => application-consumer.yml} |  16 ++-
 ...onsumer.properties => application-provider.yml} |  15 ++-
 .../{log4j.properties => application.yml}          |  28 +++--
 .../src/main/resources/logback-spring.xml          |  45 +++++++
 .../resources/spring/dubbo-consumer.properties     |  11 +-
 .../resources/spring/dubbo-provider.properties     |  11 +-
 dubbo-samples-resilience4j/pom.xml                 |   2 +-
 dubbo-samples-spring-boot-hystrix/pom.xml          |   6 +
 41 files changed, 813 insertions(+), 276 deletions(-)

diff --git 
a/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
 
b/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
index 5d21f1d..888d6cb 100644
--- 
a/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
+++ 
b/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
@@ -18,9 +18,9 @@
 
 package org.apache.dubbo.samples.api;
 
-import com.alibaba.dubbo.config.async.DubboAsync;
-
-@DubboAsync
+//import com.alibaba.dubbo.config.async.DubboAsync;
+//
+//@DubboAsync
 public interface GreetingsService {
     String sayHi(String name);
 }
diff --git 
a/dubbo-samples-async/dubbo-samples-async-generated-future/src/main/java/org/apache/dubbo/samples/governance/AsyncConsumer.java
 
b/dubbo-samples-async/dubbo-samples-async-generated-future/src/main/java/org/apache/dubbo/samples/governance/AsyncConsumer.java
index 7198a88..c5e16b1 100644
--- 
a/dubbo-samples-async/dubbo-samples-async-generated-future/src/main/java/org/apache/dubbo/samples/governance/AsyncConsumer.java
+++ 
b/dubbo-samples-async/dubbo-samples-async-generated-future/src/main/java/org/apache/dubbo/samples/governance/AsyncConsumer.java
@@ -19,26 +19,21 @@
 
 package org.apache.dubbo.samples.governance;
 
-import org.apache.dubbo.samples.api.GreetingsServiceAsync;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.util.concurrent.CompletableFuture;
-
 /**
  * CallbackConsumer
  */
 public class AsyncConsumer {
 
     public static void main(String[] args) throws Exception {
-        ClassPathXmlApplicationContext context = new 
ClassPathXmlApplicationContext(new 
String[]{"META-INF/spring/async-consumer.xml"});
-        context.start();
-
-        final GreetingsServiceAsync greetingsService = (GreetingsServiceAsync) 
context.getBean("greetingsService");
-
-        CompletableFuture<String> future = greetingsService.sayHiAsync("async 
call reqeust");
-        System.out.println("async call ret :" + future.get());
-
-        System.out.println(greetingsService.sayHi("normal sync call request"));
+//        ClassPathXmlApplicationContext context = new 
ClassPathXmlApplicationContext(new 
String[]{"META-INF/spring/async-consumer.xml"});
+//        context.start();
+//
+//        final GreetingsServiceAsync greetingsService = 
(GreetingsServiceAsync) context.getBean("greetingsService");
+//
+//        CompletableFuture<String> future = 
greetingsService.sayHiAsync("async call reqeust");
+//        System.out.println("async call ret :" + future.get());
+//
+//        System.out.println(greetingsService.sayHi("normal sync call 
request"));
 
         System.in.read();
     }
diff --git 
a/dubbo-samples-async/dubbo-samples-async-original-future/src/main/java/org/apache/dubbo/samples/governance/filter/AsyncPostprocessFilter.java
 
b/dubbo-samples-async/dubbo-samples-async-original-future/src/main/java/org/apache/dubbo/samples/governance/filter/AsyncPostprocessFilter.java
index dfc89e2..11ae85d 100644
--- 
a/dubbo-samples-async/dubbo-samples-async-original-future/src/main/java/org/apache/dubbo/samples/governance/filter/AsyncPostprocessFilter.java
+++ 
b/dubbo-samples-async/dubbo-samples-async-original-future/src/main/java/org/apache/dubbo/samples/governance/filter/AsyncPostprocessFilter.java
@@ -18,7 +18,6 @@ package org.apache.dubbo.samples.governance.filter;
 
 import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.rpc.AbstractPostProcessFilter;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
@@ -28,17 +27,17 @@ import org.apache.dubbo.rpc.RpcException;
  *
  */
 @Activate(group = {Constants.PROVIDER, Constants.CONSUMER})
-public class AsyncPostprocessFilter extends AbstractPostProcessFilter {
-    @Override
+public class AsyncPostprocessFilter {
+    //extends AbstractPostProcessFilter {
     protected Result doPostProcess(Result result, Invoker<?> invoker, 
Invocation invocation) {
         System.out.println(Thread.currentThread().getName());
         System.out.println("Filter get the return value: " + 
result.getValue());
         return result;
     }
 
-    @Override
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         System.out.println(Thread.currentThread().getName());
-        return postProcessResult(invoker.invoke(invocation), invoker, 
invocation);
+//        return postProcessResult(invoker.invoke(invocation), invoker, 
invocation);
+        return null;
     }
 }
diff --git 
a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-consumer.xml
 
b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-consumer.xml
index 47d2c73..6bb289e 100644
--- 
a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-consumer.xml
+++ 
b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-consumer.xml
@@ -38,4 +38,4 @@
     <dubbo:reference timeout="1000" id="demoService" check="false"
                      
interface="org.apache.dubbo.samples.governance.api.DemoService"/>
 
-</beans>
\ No newline at end of file
+</beans>
diff --git 
a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-provider.xml
 
b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-provider.xml
index aa65db3..63d49ef 100644
--- 
a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-provider.xml
+++ 
b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/spring/dubbo-demo-provider.xml
@@ -37,6 +37,6 @@
     <bean id="demoService" 
class="org.apache.dubbo.samples.governance.impl.DemoServiceImpl"/>
 
     <!-- declare the service interface to be exported -->
-    <dubbo:service 
interface="org.apache.dubbo.samples.governance.api.DemoService" 
ref="demoService"/>
+    <dubbo:service tag="" 
interface="org.apache.dubbo.samples.governance.api.DemoService" 
ref="demoService"/>
 
-</beans>
\ No newline at end of file
+</beans>
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jAnnotationConsumer.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jAnnotationConsumer.java
index 59e15c1..f1949d4 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jAnnotationConsumer.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jAnnotationConsumer.java
@@ -39,7 +39,7 @@ public class Resilience4jAnnotationConsumer {
         final AnnotationAction annotationAction = (AnnotationAction) 
context.getBean("annotationAction");
         String hello = annotationAction.doSayHello("world");
         System.err.println("result :" + hello);
-        annotationAction.sayCircuitBreaker("circuitBreaker");
+//        annotationAction.sayCircuitBreaker("circuitBreaker");
         annotationAction.sayRateLimiter("rateLimiter", "Just Happy!");
         System.in.read();
     }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
index 80fe535..493e944 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
@@ -31,11 +31,11 @@ import org.springframework.stereotype.Component;
 @Component("annotationAction")
 public class AnnotationAction {
 
-    @Reference
+    @Reference(interfaceClass = AnnotationService.class)
     private AnnotationService annotationService;
-    @Reference
+    @Reference(interfaceClass = CircuitBreakerService.class)
     private CircuitBreakerService circuitBreakerService;
-    @Reference
+    @Reference(interfaceClass = RateLimiterService.class)
     private RateLimiterService rateLimiterService;
 
     public String doSayHello(String name) {
@@ -49,12 +49,12 @@ public class AnnotationAction {
                 {
                     int i = 0;
                     while (true) {
-                        try {
-                            Thread.sleep(10);
-                        } catch (InterruptedException e) {
-                            e.printStackTrace();
-                        }
-                        System.out.println(circuitBreakerService.say(name + 
(i++)));
+                        doSayCircuitBreaker("off", name, 20, ++i);
+                        doSayCircuitBreaker("on", name, 25, ++i);
+                        doSayCircuitBreaker("half", name, 30, ++i);
+                        doSayCircuitBreaker("off", name, 30, ++i);
+                        doSayCircuitBreaker("half", name, 30, ++i);
+                        doSayCircuitBreaker("off", name, 15, ++i);
                     }
                 }
             }
@@ -62,6 +62,21 @@ public class AnnotationAction {
 
     }
 
+    private void doSayCircuitBreaker(String tag, String name, int c, int l) {
+        System.out.println("--------------------- start to run circuitBreak: " 
+ tag + name + "---------------------");
+        for (int i = 0; i < c; i++) {
+            try {
+                Thread.sleep(20);
+                System.out.print(System.currentTimeMillis() + " - ");
+                System.out.println(circuitBreakerService.say(tag + "-" + name 
+ "=" + l + ":" + i));
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            } catch (Throwable t) {
+                System.err.println("==" + t.getMessage());
+            }
+        }
+    }
+
     public void sayRateLimiter(String name, String value) {
         new Thread(new Runnable() {
             @Override
@@ -70,11 +85,13 @@ public class AnnotationAction {
                     int i = 0;
                     while (true) {
                         try {
-                            Thread.sleep(10);
+                            Thread.sleep(40);
+                            System.out.println(rateLimiterService.say(name + 
(i++), value + i));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
+                        } catch (Exception e) {
+                            System.err.println("<<<<<<<<<<<<<<<<<<<<<<<<<< " + 
e.getMessage() + " >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
                         }
-                        System.out.println(rateLimiterService.say(name + 
(i++), value + i));
                     }
                 }
             }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jCircuitBreakerFilter.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jCircuitBreakerFilter.java
index bfc7c10..634eacf 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jCircuitBreakerFilter.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jCircuitBreakerFilter.java
@@ -20,24 +20,33 @@ package org.apache.dubbo.samples.resilience4j.filter;
 
 import io.github.resilience4j.circuitbreaker.CircuitBreaker;
 import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
+import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException;
 import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
+import io.github.resilience4j.circuitbreaker.utils.CircuitBreakerUtils;
 import org.apache.dubbo.rpc.Filter;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcException;
 
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
- * @author cvictory ON 2018/12/25
+ * 2018/12/25
  */
 public class Resilience4jCircuitBreakerFilter implements Filter {
 
     static CircuitBreaker circuitBreaker;
+    static AtomicLong count = new AtomicLong(0);
+    static AtomicLong breakCount = new AtomicLong(0);
 
     static {
         CircuitBreakerConfig config = CircuitBreakerConfig.custom()
                 .failureRateThreshold(20)
-                .ringBufferSizeInClosedState(5)
+                .waitDurationInOpenState(Duration.ofMillis(6000))
+                .ringBufferSizeInHalfOpenState(10)
+                .ringBufferSizeInClosedState(10)
                 .build();
         CircuitBreakerRegistry registry = CircuitBreakerRegistry.of(config);
         circuitBreaker = registry.circuitBreaker("myCircuitBreaker");
@@ -46,17 +55,35 @@ public class Resilience4jCircuitBreakerFilter implements 
Filter {
     @Override
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         System.out.println("**************** Enter CircuitBreaker 
****************");
-        long start = System.nanoTime();
+        long countLong = count.incrementAndGet();
+        long start = 0;
         try {
+            CircuitBreakerUtils.isCallPermitted(circuitBreaker);
+            start = System.nanoTime();
             Result result = invoker.invoke(invocation);
+            if (result.hasException()) {
+                doThrowException(result.getException(), start);
+                return result;
+            }
             long durationInNanos = System.nanoTime() - start;
             circuitBreaker.onSuccess(durationInNanos);
             return result;
+        } catch (CircuitBreakerOpenException cbo) {
+
+            doCircuitBreakerOpenException(cbo, countLong, 
breakCount.incrementAndGet());
+            throw cbo;
         } catch (Throwable throwable) {
-            System.out.println("************* CircuitBreaker! Try it later! 
*************");
-            long durationInNanos = System.nanoTime() - start;
-            circuitBreaker.onError(durationInNanos, throwable);
+            doThrowException(throwable, start);
             throw throwable;
         }
     }
+
+    private void doThrowException(Throwable throwable, long start) {
+        long durationInNanos = System.nanoTime() - start;
+        circuitBreaker.onError(durationInNanos, throwable);
+    }
+
+    private void doCircuitBreakerOpenException(Throwable throwable, long 
count, long breakCount) {
+        System.err.println("---------------------------- Open CircuitBreaker! 
Try it later! ----------------------------" + breakCount + " / " + count);
+    }
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jRateLimiterFilter.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jRateLimiterFilter.java
index 65ce4bf..f0a38e5 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jRateLimiterFilter.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/filter/Resilience4jRateLimiterFilter.java
@@ -21,6 +21,7 @@ package org.apache.dubbo.samples.resilience4j.filter;
 import io.github.resilience4j.ratelimiter.RateLimiter;
 import io.github.resilience4j.ratelimiter.RateLimiterConfig;
 import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
+import io.github.resilience4j.ratelimiter.RequestNotPermitted;
 import org.apache.dubbo.rpc.Filter;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
@@ -30,9 +31,8 @@ import org.apache.dubbo.rpc.RpcException;
 import java.time.Duration;
 
 
-
 /**
- * @author cvictory ON 2018/12/25
+ * 2018/12/25
  */
 public class Resilience4jRateLimiterFilter implements Filter {
 
@@ -41,8 +41,8 @@ public class Resilience4jRateLimiterFilter implements Filter {
     static {
         RateLimiterConfig config = RateLimiterConfig.custom()
                 .limitRefreshPeriod(Duration.ofMillis(1000))
-                .limitForPeriod(2)
-                .timeoutDuration(Duration.ofMillis(2000))
+                .limitForPeriod(10)
+                .timeoutDuration(Duration.ofMillis(200))
                 .build();
 
         RateLimiterRegistry rateLimiterRegistry = 
RateLimiterRegistry.of(config);
@@ -55,8 +55,11 @@ public class Resilience4jRateLimiterFilter implements Filter 
{
             System.out.println("**************** Enter RateLimiter 
****************");
             RateLimiter.waitForPermission(rateLimiter);
             return invoker.invoke(invocation);
+        } catch (RequestNotPermitted rnp) {
+            System.err.println("---------------- Rate Limiter! Try it later! 
----------------");
+            throw rnp;
         } catch (Throwable throwable) {
-            System.out.println("************* Rate Limiter! Try it later! 
*************");
+            System.err.println("........" + throwable.getMessage());
             throw throwable;
         }
     }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
index d2dc0ec..72d7919 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
@@ -25,7 +25,7 @@ import 
org.apache.dubbo.samples.resilience4j.api.AnnotationService;
 /**
  * AsyncServiceImpl
  */
-@Service
+@Service(interfaceClass = AnnotationService.class)
 public class AnnotationServiceImpl implements AnnotationService {
 
     //    @HystrixCommand(commandProperties = { @HystrixProperty(name = 
"circuitBreaker.requestVolumeThreshold", value = "10"),
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
index 9853d35..608d820 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
@@ -21,13 +21,23 @@ package org.apache.dubbo.samples.resilience4j.impl;
 import org.apache.dubbo.config.annotation.Service;
 import org.apache.dubbo.samples.resilience4j.api.CircuitBreakerService;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * 2018/12/26
  */
-@Service
+@Service(interfaceClass = CircuitBreakerService.class)
 public class CircuitBreakerServiceImpl implements CircuitBreakerService {
+    private AtomicLong count = new AtomicLong(0);
+
     @Override
     public String say(String name) {
-        throw new RuntimeException("Exception to show resilience enabled.");
+        long countLong = count.incrementAndGet();
+        if (name.startsWith("half") && countLong % 20 < 18) {
+            return "Hello " + name + " - " + countLong;
+        } else if (name.startsWith("off")) {
+            return "Hello " + name + " - " + countLong;
+        }
+        throw new RuntimeException("Exception to show resilience enabled." + 
name);
     }
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
index bccaafc..a55ef91 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
@@ -24,7 +24,7 @@ import 
org.apache.dubbo.samples.resilience4j.api.RateLimiterService;
 /**
  * 2018/12/26
  */
-@Service
+@Service(interfaceClass = RateLimiterService.class)
 public class RateLimiterServiceImpl implements RateLimiterService {
     @Override
     public String say(String name, String value) {
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-consumer.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-consumer.properties
index 5ebcaad..507dbeb 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-consumer.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-consumer.properties
@@ -17,7 +17,8 @@
 #
 #
 
-dubbo.application.name=annotation-consumer
+dubbo.application.name=resilience4j-annotation-consumer
 dubbo.registry.address=zookeeper://127.0.0.1:2181
 dubbo.consumer.timeout=3000
 dubbo.consumer.filter=circuitBreaker
+dubbo.consumer.retries=-1
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-provider.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-provider.properties
index 9331899..55e67cf 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-provider.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/resources/spring/dubbo-provider.properties
@@ -17,7 +17,7 @@
 #
 #
 
-dubbo.application.name=annotation-provider
+dubbo.application.name=resilience4j-annotation-provider
 dubbo.registry.address=zookeeper://127.0.0.1:2181
 dubbo.protocol.name=dubbo
 dubbo.protocol.port=20880
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/pom.xml 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/pom.xml
index 862a475..06bcdc1 100644
--- a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/pom.xml
+++ b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/pom.xml
@@ -35,6 +35,18 @@
         <resilience4j.version>0.13.1</resilience4j.version>
     </properties>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <!-- Import dependency management from Spring Boot -->
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>2.1.1.RELEASE</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
 
     <dependencies>
         <dependency>
@@ -68,8 +80,91 @@
             <version>${resilience4j.version}</version>
         </dependency>
         <dependency>
+            <groupId>io.github.resilience4j</groupId>
+            <artifactId>resilience4j-spring-boot2</artifactId>
+            <version>${resilience4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.resilience4j</groupId>
+            <artifactId>resilience4j-metrics</artifactId>
+            <version>${resilience4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.resilience4j</groupId>
+            <artifactId>resilience4j-micrometer</artifactId>
+            <version>${resilience4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>net.logstash.logback</groupId>
+            <artifactId>logstash-logback-encoder</artifactId>
+            <version>5.2</version>
+        </dependency>
+        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.validator</groupId>
+            <artifactId>hibernate-validator</artifactId>
+            <version>6.0.13.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>2.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>999-not-exist-v3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+            <version>1.7.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <version>1.7.9</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>999-not-exist-v3</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>999-not-exist</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <version>9.0.13</version>
+        </dependency>
+        <!--<dependency>-->
+        <!--<groupId>com.alibaba.boot</groupId>-->
+        <!--<artifactId>dubbo-spring-boot-starter</artifactId>-->
+        <!--<version>0.2.0</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--<groupId>io.prometheus</groupId>-->
+        <!--<artifactId>simpleclient_spring_boot</artifactId>-->
+        <!--<version>0.0.25</version>-->
+        <!--</dependency>-->
     </dependencies>
 </project>
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationConsumer.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationConsumer.java
deleted file mode 100644
index d6ac170..0000000
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationConsumer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-
-package org.apache.dubbo.samples.resilience4j;
-
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.samples.resilience4j.action.AnnotationAction;
-import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.context.annotation.PropertySource;
-
-/**
- * CallbackConsumer
- */
-public class Resilience4jBootAnnotationConsumer {
-
-    public static void main(String[] args) throws Exception {
-        AnnotationConfigApplicationContext context = new 
AnnotationConfigApplicationContext(ConsumerConfiguration.class);
-        context.start();
-        final AnnotationAction annotationAction = (AnnotationAction) 
context.getBean("annotationAction");
-        String hello = annotationAction.doSayHello("world");
-        System.err.println("result :" + hello);
-        System.in.read();
-    }
-
-    @Configuration
-    @EnableDubbo(scanBasePackages = 
"com.alibaba.dubbo.samples.resilience4j.action")
-    @PropertySource("classpath:/spring/dubbo-consumer.properties")
-    @ComponentScan(value = {"org.apache.dubbo.samples.resilience4j.action"})
-    @EnableAspectJAutoProxy
-    static public class ConsumerConfiguration {
-
-//        @Bean
-//        public HystrixCommandAspect hystrixCommandAspect() {
-//            return new HystrixCommandAspect();
-//        }
-
-    }
-
-}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationProvider.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationProvider.java
deleted file mode 100644
index c789eca..0000000
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/Resilience4jBootAnnotationProvider.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-
-package org.apache.dubbo.samples.resilience4j;
-
-
-import org.apache.dubbo.config.ProviderConfig;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.context.annotation.PropertySource;
-
-/**
- * MergeProvider
- */
-public class Resilience4jBootAnnotationProvider {
-
-    public static void main(String[] args) throws Exception {
-        new EmbeddedZooKeeper(2181, false).start();
-        AnnotationConfigApplicationContext context = new 
AnnotationConfigApplicationContext(ProviderConfiguration.class);
-        context.start();
-        System.in.read();
-    }
-
-    @Configuration
-    @EnableDubbo(scanBasePackages = 
"com.alibaba.dubbo.samples.resilience4j.impl")
-    @PropertySource("classpath:/spring/dubbo-provider.properties")
-    @EnableAspectJAutoProxy
-    static public class ProviderConfiguration {
-        @Bean
-        public ProviderConfig providerConfig() {
-            ProviderConfig providerConfig = new ProviderConfig();
-            providerConfig.setTimeout(1000);
-            return providerConfig;
-        }
-
-//        @Bean
-//        public HystrixCommandAspect hystrixCommandAspect() {
-//            return new HystrixCommandAspect();
-//        }
-    }
-
-}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/EmbeddedZooKeeper.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/EmbeddedZooKeeper.java
similarity index 99%
rename from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/EmbeddedZooKeeper.java
rename to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/EmbeddedZooKeeper.java
index 9c8ae8a..80a2adf 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/EmbeddedZooKeeper.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/EmbeddedZooKeeper.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.dubbo.samples.resilience4j;
+package org.apache.dubbo.samples.resilience4jboot2;
 
 import java.io.File;
 import java.lang.reflect.Method;
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/AnnotationService.java
similarity index 94%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/AnnotationService.java
index 74b849a..af261c5 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/AnnotationService.java
@@ -17,7 +17,7 @@
  *
  */
 
-package org.apache.dubbo.samples.resilience4j.api;
+package org.apache.dubbo.samples.resilience4jboot2.api;
 
 /**
  * AsyncService
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/CircuitBreakerService.java
similarity index 85%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/CircuitBreakerService.java
index 74b849a..5da9786 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/CircuitBreakerService.java
@@ -16,14 +16,12 @@
  *   limitations under the License.
  *
  */
-
-package org.apache.dubbo.samples.resilience4j.api;
+package org.apache.dubbo.samples.resilience4jboot2.api;
 
 /**
- * AsyncService
+ * 2018/12/26
  */
-public interface AnnotationService {
-
-    String sayHello(String name);
+public interface CircuitBreakerService {
 
+    String say(String name);
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/RateLimiterService.java
similarity index 84%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/RateLimiterService.java
index 74b849a..0686f58 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/api/RateLimiterService.java
@@ -16,14 +16,12 @@
  *   limitations under the License.
  *
  */
-
-package org.apache.dubbo.samples.resilience4j.api;
+package org.apache.dubbo.samples.resilience4jboot2.api;
 
 /**
- * AsyncService
+ * 2018/12/26
  */
-public interface AnnotationService {
-
-    String sayHello(String name);
+public interface RateLimiterService {
 
+    String say(String name, String value);
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/Resilience4jBootConsumerApplication.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/Resilience4jBootConsumerApplication.java
new file mode 100644
index 0000000..3449458
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/Resilience4jBootConsumerApplication.java
@@ -0,0 +1,57 @@
+/*
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements.  See the NOTICE file distributed with
+ *   this work for additional information regarding copyright ownership.
+ *   The ASF licenses this file to You under the Apache License, Version 2.0
+ *   (the "License"); you may not use this file except in compliance with
+ *   the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.resilience4jboot2.consumer;
+
+import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
+import 
io.github.resilience4j.circuitbreaker.monitoring.health.CircuitBreakerHealthIndicator;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * CallbackConsumer
+ */
+@SpringBootApplication
+//@EnableSpringBootMetricsCollector
+//@EnablePrometheusEndpoint
+@EnableConfigurationProperties
+@EnableDubbo(scanBasePackages = 
"org.apache.dubbo.samples.resilience4jboot2.consumer.action")
+@PropertySource("classpath:/spring/dubbo-consumer.properties")
+public class Resilience4jBootConsumerApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(Resilience4jBootConsumerApplication.class, args);
+    }
+
+    @Bean
+    public HealthIndicator backendA(CircuitBreakerRegistry 
circuitBreakerRegistry){
+        return new 
CircuitBreakerHealthIndicator(circuitBreakerRegistry.circuitBreaker("backendA"));
+    }
+
+    @Bean
+    public HealthIndicator backendB(CircuitBreakerRegistry 
circuitBreakerRegistry){
+        return new 
CircuitBreakerHealthIndicator(circuitBreakerRegistry.circuitBreaker("backendB"));
+    }
+
+}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/AnnotationAction.java
similarity index 81%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/AnnotationAction.java
index c70051a..e1a073a 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/AnnotationAction.java
@@ -17,10 +17,10 @@
  *
  */
 
-package org.apache.dubbo.samples.resilience4j.action;
+package org.apache.dubbo.samples.resilience4jboot2.consumer.action;
 
 import org.apache.dubbo.config.annotation.Reference;
-import org.apache.dubbo.samples.resilience4j.api.AnnotationService;
+import org.apache.dubbo.samples.resilience4jboot2.api.AnnotationService;
 import org.springframework.stereotype.Component;
 
 /**
@@ -29,16 +29,12 @@ import org.springframework.stereotype.Component;
 @Component("annotationAction")
 public class AnnotationAction {
 
-    @Reference
+    @Reference(interfaceClass = AnnotationService.class)
     private AnnotationService annotationService;
 
-//    @HystrixCommand(fallbackMethod = "reliable")
     public String doSayHello(String name) {
         return annotationService.sayHello(name);
     }
 
-    public String reliable(String name) {
-        return "hystrix fallback value";
-    }
 
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakMethodWrapper.java
similarity index 63%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakMethodWrapper.java
index c70051a..c2c08be 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakMethodWrapper.java
@@ -16,29 +16,23 @@
  *   limitations under the License.
  *
  */
+package org.apache.dubbo.samples.resilience4jboot2.consumer.action;
 
-package org.apache.dubbo.samples.resilience4j.action;
-
+import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
 import org.apache.dubbo.config.annotation.Reference;
-import org.apache.dubbo.samples.resilience4j.api.AnnotationService;
+import org.apache.dubbo.samples.resilience4jboot2.api.CircuitBreakerService;
 import org.springframework.stereotype.Component;
 
 /**
- * AnnotationAction
+ * 2019/1/2
  */
-@Component("annotationAction")
-public class AnnotationAction {
-
-    @Reference
-    private AnnotationService annotationService;
+@Component("circuitBreakMethodWrapper")
+public class CircuitBreakMethodWrapper {
+    @Reference(interfaceClass = CircuitBreakerService.class)
+    private CircuitBreakerService circuitBreakerService;
 
-//    @HystrixCommand(fallbackMethod = "reliable")
-    public String doSayHello(String name) {
-        return annotationService.sayHello(name);
+    @CircuitBreaker(name = "backendB")
+    public String say(String name) {
+        return circuitBreakerService.say(name);
     }
-
-    public String reliable(String name) {
-        return "hystrix fallback value";
-    }
-
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakTypeWrapper.java
similarity index 63%
rename from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
rename to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakTypeWrapper.java
index c70051a..8cff9f2 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/action/AnnotationAction.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakTypeWrapper.java
@@ -16,29 +16,23 @@
  *   limitations under the License.
  *
  */
+package org.apache.dubbo.samples.resilience4jboot2.consumer.action;
 
-package org.apache.dubbo.samples.resilience4j.action;
-
+import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
 import org.apache.dubbo.config.annotation.Reference;
-import org.apache.dubbo.samples.resilience4j.api.AnnotationService;
+import org.apache.dubbo.samples.resilience4jboot2.api.CircuitBreakerService;
 import org.springframework.stereotype.Component;
 
 /**
- * AnnotationAction
+ * 2019/1/2
  */
-@Component("annotationAction")
-public class AnnotationAction {
-
-    @Reference
-    private AnnotationService annotationService;
+@Component("circuitBreakTypeWrapper")
+@CircuitBreaker(name = "backendA")
+public class CircuitBreakTypeWrapper {
+    @Reference(interfaceClass = CircuitBreakerService.class)
+    private CircuitBreakerService circuitBreakerService;
 
-//    @HystrixCommand(fallbackMethod = "reliable")
-    public String doSayHello(String name) {
-        return annotationService.sayHello(name);
+    public String say(String name) {
+        return circuitBreakerService.say(name);
     }
-
-    public String reliable(String name) {
-        return "hystrix fallback value";
-    }
-
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakerAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakerAction.java
new file mode 100644
index 0000000..0c47b29
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/CircuitBreakerAction.java
@@ -0,0 +1,138 @@
+/*
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements.  See the NOTICE file distributed with
+ *   this work for additional information regarding copyright ownership.
+ *   The ASF licenses this file to You under the Apache License, Version 2.0
+ *   (the "License"); you may not use this file except in compliance with
+ *   the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.resilience4jboot2.consumer.action;
+
+import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * AnnotationAction
+ */
+@Component("circuitBreakerAction")
+public class CircuitBreakerAction {
+
+    @Autowired
+    private CircuitBreakTypeWrapper circuitBreakTypeWrapper;
+
+    @Autowired
+    private CircuitBreakMethodWrapper circuitBreakMethodWrapper;
+
+
+    private Thread circuitBreakerThread = new Thread(new Runnable() {
+        @Override
+        public void run() {
+            {
+                int i = 0;
+                while (true) {
+                    doSayCircuitBreaker("off", "circuitBreaker", 20, ++i);
+                    doSayCircuitBreaker("on", "circuitBreaker", 25, ++i);
+                    doSayCircuitBreaker("half", "circuitBreaker", 30, ++i);
+                    doSayCircuitBreaker("off", "circuitBreaker", 30, ++i);
+                    doSayCircuitBreaker("half", "circuitBreaker", 30, ++i);
+                    doSayCircuitBreaker("off", "circuitBreaker", 15, ++i);
+                }
+            }
+        }
+    });
+
+    private Thread circuitBreakerMethodThread = new Thread(new Runnable() {
+        @Override
+        public void run() {
+            {
+                int i = 0;
+                while (true) {
+                    doSayCircuitBreakerMethod("off", "circuitBreaker", 20, 
++i);
+                    doSayCircuitBreakerMethod("on", "circuitBreaker", 8, ++i);
+                    doSayCircuitBreakerMethod("half", "circuitBreaker", 30, 
++i);
+                    doSayCircuitBreakerMethod("off", "circuitBreaker", 30, 
++i);
+                    doSayCircuitBreakerMethod("half", "circuitBreaker", 30, 
++i);
+                    doSayCircuitBreakerMethod("off", "circuitBreaker", 32, 
++i);
+                }
+            }
+        }
+    });
+
+    public void sayCircuitBreaker() {
+        if (circuitBreakerThread.getState() == Thread.State.NEW) {
+            circuitBreakerThread.start();
+        }
+    }
+
+    public void suspendCircuitBreaker() {
+        circuitBreakerThread.suspend();
+    }
+
+    public void resumeCircuitBreaker() {
+        circuitBreakerThread.resume();
+
+    }
+
+    private void doSayCircuitBreaker(String tag, String name, int c, int l) {
+        System.out.println("--------------------- start to run circuitBreak: " 
+ tag + name + "---------------------");
+        for (int i = 0; i < c; i++) {
+            try {
+                Thread.sleep(20);
+                System.out.print(System.currentTimeMillis() + " - ");
+                System.out.println(circuitBreakTypeWrapper.say(tag + "-" + 
name + "=" + l + ":" + i));
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            } catch (CircuitBreakerOpenException t) {
+                System.err.println("== " + l + ":" + i + " " + t.toString());
+            } catch (Throwable t) {
+                System.err.println("== " + l + ":" + i + " " + t.toString());
+            }
+        }
+    }
+
+
+    public void sayCircuitBreakerMethod() {
+        if (circuitBreakerMethodThread.getState() == Thread.State.NEW) {
+            circuitBreakerMethodThread.start();
+        }
+    }
+
+    public void suspendCircuitBreakerMethod() {
+        circuitBreakerMethodThread.suspend();
+    }
+
+    public void resumeCircuitBreakerMethod() {
+        circuitBreakerMethodThread.resume();
+
+    }
+
+    private void doSayCircuitBreakerMethod(String tag, String name, int c, int 
l) {
+        System.out.println("--------------------- start to run circuitBreak: " 
+ tag + name + "---------------------");
+        for (int i = 0; i < c; i++) {
+            try {
+                Thread.sleep(20);
+                System.out.print(System.currentTimeMillis() + " - ");
+                System.out.println(circuitBreakMethodWrapper.say(tag + "-" + 
name + "=" + l + ":" + i));
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            } catch (CircuitBreakerOpenException t) {
+                System.err.println("== " + l + ":" + i + " " + t.toString());
+            } catch (Throwable t) {
+                System.err.println("== " + l + ":" + i + " " + t.toString());
+            }
+        }
+    }
+
+}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/RateLimiterAction.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/RateLimiterAction.java
new file mode 100644
index 0000000..2b044c6
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/action/RateLimiterAction.java
@@ -0,0 +1,75 @@
+/*
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements.  See the NOTICE file distributed with
+ *   this work for additional information regarding copyright ownership.
+ *   The ASF licenses this file to You under the Apache License, Version 2.0
+ *   (the "License"); you may not use this file except in compliance with
+ *   the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.resilience4jboot2.consumer.action;
+
+import org.apache.dubbo.config.annotation.Reference;
+import org.apache.dubbo.samples.resilience4jboot2.api.RateLimiterService;
+import org.springframework.stereotype.Component;
+
+/**
+ * AnnotationAction
+ */
+@Component("rateLimiterAction")
+public class RateLimiterAction {
+
+    @Reference(interfaceClass = RateLimiterService.class)
+    private RateLimiterService rateLimiterService;
+
+    private Thread rateThread = new Thread(new Runnable() {
+        @Override
+        public void run() {
+            {
+                int i = 0;
+                while (true) {
+                    try {
+                        Thread.sleep(40);
+                        System.out.println(rateLimiterService.say("rateK" + 
(i++), "rateV" + i));
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    } catch (Exception e) {
+                        System.err.println("<<<<<<<<<<<<<<<<<<<<<<<<<< " + 
e.getMessage() + " >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+                    }
+                }
+            }
+        }
+    });
+
+
+    public void sayRateLimiter() {
+        if (rateThread.getState() == Thread.State.NEW) {
+            rateThread.start();
+        }
+    }
+
+    public void suspendRateLimiter() {
+        rateThread.suspend();
+    }
+
+    public void resumeRateLimiterr() {
+        rateThread.resume();
+
+    }
+
+
+    public String reliable(String name) {
+        return "hystrix fallback value";
+    }
+
+}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/controller/TestController.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/controller/TestController.java
new file mode 100644
index 0000000..64498ca
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/consumer/controller/TestController.java
@@ -0,0 +1,103 @@
+/*
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements.  See the NOTICE file distributed with
+ *   this work for additional information regarding copyright ownership.
+ *   The ASF licenses this file to You under the Apache License, Version 2.0
+ *   (the "License"); you may not use this file except in compliance with
+ *   the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.resilience4jboot2.consumer.controller;
+
+import 
org.apache.dubbo.samples.resilience4jboot2.consumer.action.AnnotationAction;
+import 
org.apache.dubbo.samples.resilience4jboot2.consumer.action.CircuitBreakerAction;
+import 
org.apache.dubbo.samples.resilience4jboot2.consumer.action.RateLimiterAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 2018/12/28
+ */
+@RestController
+public class TestController {
+
+    @Autowired
+    private AnnotationAction annotationAction;
+
+    @Autowired
+    private CircuitBreakerAction circuitBreakerAction;
+
+    @Autowired
+    private RateLimiterAction rateLimiterAction;
+
+    @RequestMapping("/test")
+    public String test() {
+        return annotationAction.doSayHello(" test");
+    }
+
+    @RequestMapping("/rate")
+    public String rate() {
+        rateLimiterAction.sayRateLimiter();
+        return "look at console . rate";
+    }
+
+    @RequestMapping("/suspend_rate")
+    public String suspend_rate() {
+        rateLimiterAction.suspendRateLimiter();
+        return "look at console . suspend_rate";
+    }
+
+    @RequestMapping("/resume_rate")
+    public String resume_rate() {
+        rateLimiterAction.resumeRateLimiterr();
+        return "look at console . resume_rate";
+    }
+
+    @RequestMapping("/circuitBreaker")
+    public String circuitBreaker() {
+        circuitBreakerAction.sayCircuitBreaker();
+        return "look at console. circuitBreaker";
+    }
+
+    @RequestMapping("/suspend_circuit_breaker")
+    public String suspend_CircuitBreaker() {
+        circuitBreakerAction.suspendCircuitBreaker();
+        return "look at console . suspend_CircuitBreaker";
+    }
+
+    @RequestMapping("/resume_circuit_breaker")
+    public String resume_CircuitBreaker() {
+        circuitBreakerAction.resumeCircuitBreaker();
+        return "look at console . resume_CircuitBreaker";
+    }
+
+    @RequestMapping("/circuitBreakerMethod")
+    public String circuitBreakerMethod() {
+        circuitBreakerAction.sayCircuitBreakerMethod();
+        return "look at console. circuitBreakerMethod";
+    }
+
+    @RequestMapping("/suspend_circuit_breaker_method")
+    public String suspendCircuitBreakerMethod() {
+        circuitBreakerAction.suspendCircuitBreakerMethod();
+        return "look at console . suspend_CircuitBreakerMethod";
+    }
+
+    @RequestMapping("/resume_circuit_breaker_method")
+    public String resumeCircuitBreakerMethod() {
+        circuitBreakerAction.resumeCircuitBreakerMethod();
+        return "look at console . resume_CircuitBreakerMethod";
+    }
+
+}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/DubbConfiguration.java
similarity index 64%
rename from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
rename to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/DubbConfiguration.java
index 74b849a..4080270 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/api/AnnotationService.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/DubbConfiguration.java
@@ -16,14 +16,17 @@
  *   limitations under the License.
  *
  */
+package org.apache.dubbo.samples.resilience4jboot2.provider;
 
-package org.apache.dubbo.samples.resilience4j.api;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
 
 /**
- * AsyncService
+ * 2019/1/2
  */
-public interface AnnotationService {
-
-    String sayHello(String name);
-
+@Configuration
+@EnableDubbo(scanBasePackages = 
"org.apache.dubbo.samples.resilience4jboot2.provider.impl")
+@PropertySource("classpath:/spring/dubbo-provider.properties")
+public class DubbConfiguration {
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/Resilience4jBootProviderApplication.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/Resilience4jBootProviderApplication.java
new file mode 100644
index 0000000..c3bee83
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/Resilience4jBootProviderApplication.java
@@ -0,0 +1,67 @@
+/*
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements.  See the NOTICE file distributed with
+ *   this work for additional information regarding copyright ownership.
+ *   The ASF licenses this file to You under the Apache License, Version 2.0
+ *   (the "License"); you may not use this file except in compliance with
+ *   the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.resilience4jboot2.provider;
+
+
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+
+import java.io.IOException;
+
+/**
+ * MergeProvider
+ */
+@SpringBootApplication
+//@EnableSpringBootMetricsCollector
+//@EnablePrometheusEndpoint
+@EnableConfigurationProperties
+public class Resilience4jBootProviderApplication implements CommandLineRunner {
+
+    public static void main(String[] args) throws IOException {
+        SpringApplication application = new SpringApplication(new Class<?>[] { 
Resilience4jBootProviderApplication.class });
+        application.setAdditionalProfiles("provider");
+        application.run(args);
+    }
+
+    @Override
+    public void run(String... args) throws Exception {
+        Thread.currentThread().join();
+    }
+
+//    @Bean
+//    public HealthIndicator backendA(CircuitBreakerRegistry 
circuitBreakerRegistry){
+//        return new 
CircuitBreakerHealthIndicator(circuitBreakerRegistry.circuitBreaker("backendA"));
+//    }
+//
+//    @Bean
+//    public HealthIndicator backendB(CircuitBreakerRegistry 
circuitBreakerRegistry){
+//        return new 
CircuitBreakerHealthIndicator(circuitBreakerRegistry.circuitBreaker("backendB"));
+//    }
+
+//    @Bean
+//    public ProviderConfig providerConfig() {
+//        ProviderConfig providerConfig = new ProviderConfig();
+//        providerConfig.setTimeout(1000);
+//        return providerConfig;
+//    }
+
+}
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/AnnotationServiceImpl.java
similarity index 77%
rename from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
rename to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/AnnotationServiceImpl.java
index cc2e9f7..ee8175c 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4j/impl/AnnotationServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/AnnotationServiceImpl.java
@@ -17,24 +17,24 @@
  *
  */
 
-package org.apache.dubbo.samples.resilience4j.impl;
+package org.apache.dubbo.samples.resilience4jboot2.provider.impl;
 
 import org.apache.dubbo.config.annotation.Service;
-import org.apache.dubbo.samples.resilience4j.api.AnnotationService;
+import org.apache.dubbo.samples.resilience4jboot2.api.AnnotationService;
 
 /**
  * AsyncServiceImpl
  */
-@Service
+@Service(interfaceClass = AnnotationService.class)
 public class AnnotationServiceImpl implements AnnotationService {
 
-//    @HystrixCommand(commandProperties = { @HystrixProperty(name = 
"circuitBreaker.requestVolumeThreshold", value = "10"),
+    //    @HystrixCommand(commandProperties = { @HystrixProperty(name = 
"circuitBreaker.requestVolumeThreshold", value = "10"),
 //                    @HystrixProperty(name = 
"execution.isolation.thread.timeoutInMilliseconds", value = "2000") })
     @Override
     public String sayHello(String name) {
 //        System.out.println("async provider received: " + name);
 //        return "annotation: hello, " + name;
-        throw new RuntimeException("Exception to show hystrix enabled.");
+        return "Hello, " + name + "! this is annotation.";
     }
 
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/CircuitBreakerServiceImpl.java
similarity index 64%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/CircuitBreakerServiceImpl.java
index 9853d35..0b1a2b2 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/CircuitBreakerServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/CircuitBreakerServiceImpl.java
@@ -16,18 +16,28 @@
  *   limitations under the License.
  *
  */
-package org.apache.dubbo.samples.resilience4j.impl;
+package org.apache.dubbo.samples.resilience4jboot2.provider.impl;
 
 import org.apache.dubbo.config.annotation.Service;
-import org.apache.dubbo.samples.resilience4j.api.CircuitBreakerService;
+import org.apache.dubbo.samples.resilience4jboot2.api.CircuitBreakerService;
+
+import java.util.concurrent.atomic.AtomicLong;
 
 /**
  * 2018/12/26
  */
-@Service
+@Service(interfaceClass = CircuitBreakerService.class)
 public class CircuitBreakerServiceImpl implements CircuitBreakerService {
+    private AtomicLong count = new AtomicLong(0);
+
     @Override
     public String say(String name) {
-        throw new RuntimeException("Exception to show resilience enabled.");
+        long countLong = count.incrementAndGet();
+        if (name.startsWith("half") && countLong % 20 < 18) {
+            return "Hello " + name + " - " + countLong;
+        } else if (name.startsWith("off")) {
+            return "Hello " + name + " - " + countLong;
+        }
+        throw new RuntimeException("Exception to show resilience enabled." + 
name);
     }
 }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/RateLimiterServiceImpl.java
similarity index 79%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/RateLimiterServiceImpl.java
index bccaafc..9b74247 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-filter/src/main/java/org/apache/dubbo/samples/resilience4j/impl/RateLimiterServiceImpl.java
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/java/org/apache/dubbo/samples/resilience4jboot2/provider/impl/RateLimiterServiceImpl.java
@@ -16,17 +16,19 @@
  *   limitations under the License.
  *
  */
-package org.apache.dubbo.samples.resilience4j.impl;
+package org.apache.dubbo.samples.resilience4jboot2.provider.impl;
 
+import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
 import org.apache.dubbo.config.annotation.Service;
-import org.apache.dubbo.samples.resilience4j.api.RateLimiterService;
+import org.apache.dubbo.samples.resilience4jboot2.api.RateLimiterService;
 
 /**
  * 2018/12/26
  */
-@Service
+@Service(interfaceClass = RateLimiterService.class)
 public class RateLimiterServiceImpl implements RateLimiterService {
     @Override
+    @RateLimiter(name = "limiterA")
     public String say(String name, String value) {
         return "Hello " + name + ", this is rateLimiter. The value is :" + 
value;
     }
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-consumer.yml
similarity index 85%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-consumer.yml
index 96ab667..a553f43 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-consumer.yml
@@ -6,17 +6,21 @@
 #   The ASF licenses this file to You under the Apache License, Version 2.0
 #   (the "License"); you may not use this file except in compliance with
 #   the License.  You may obtain a copy of the License at
-#  
+#
 #       http://www.apache.org/licenses/LICENSE-2.0
-#  
+#
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-#  
 #
+#
+
+spring:
+  application.name: dubbo-resilience4j-springboot2-consumer
+  jackson.serialization.indent_output: true
+
+server:
+  port: 9082
 
-dubbo.application.name=annotation-consumer
-dubbo.registry.address=zookeeper://127.0.0.1:2181
-dubbo.consumer.timeout=3000
\ No newline at end of file
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-provider.yml
similarity index 85%
copy from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
copy to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-provider.yml
index 96ab667..9ac9c8e 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application-provider.yml
@@ -6,17 +6,20 @@
 #   The ASF licenses this file to You under the Apache License, Version 2.0
 #   (the "License"); you may not use this file except in compliance with
 #   the License.  You may obtain a copy of the License at
-#  
+#
 #       http://www.apache.org/licenses/LICENSE-2.0
-#  
+#
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-#  
 #
+#
+
+spring:
+  application.name: dubbo-resilience4j-springboot2-provider
+  jackson.serialization.indent_output: true
 
-dubbo.application.name=annotation-consumer
-dubbo.registry.address=zookeeper://127.0.0.1:2181
-dubbo.consumer.timeout=3000
\ No newline at end of file
+server:
+  port: 9080
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/log4j.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application.yml
similarity index 58%
rename from 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/log4j.properties
rename to 
dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application.yml
index d6ecd5c..2c52971 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/log4j.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/application.yml
@@ -17,10 +17,24 @@
 #
 #
 
-###set log levels###
-log4j.rootLogger=info, stdout
-###output to the console###
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] 
%t %5p %c{2}: %m%n
\ No newline at end of file
+resilience4j:
+  circuitbreaker:
+    backends:
+      backendA:
+        ringBufferSizeInClosedState: 10
+        ringBufferSizeInHalfOpenState: 10
+        waitInterval: 6000
+        failureRateThreshold: 20
+#        eventConsumerBufferSize: 10
+      backendB:
+        ringBufferSizeInClosedState: 10
+        ringBufferSizeInHalfOpenState: 10
+        waitInterval: 2000
+        failureRateThreshold: 50
+#        eventConsumerBufferSize: 10
+  ratelimiter:
+    limiters:
+      limiterA:
+        limitForPeriod: 10
+        limitRefreshPeriodInMillis: 1000
+        timeoutInMillis: 200
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/logback-spring.xml
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..38637bf
--- /dev/null
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/logback-spring.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~
+  ~   Licensed to the Apache Software Foundation (ASF) under one or more
+  ~   contributor license agreements.  See the NOTICE file distributed with
+  ~   this work for additional information regarding copyright ownership.
+  ~   The ASF licenses this file to You under the Apache License, Version 2.0
+  ~   (the "License"); you may not use this file except in compliance with
+  ~   the License.  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~   Unless required by applicable law or agreed to in writing, software
+  ~   distributed under the License is distributed on an "AS IS" BASIS,
+  ~   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~   See the License for the specific language governing permissions and
+  ~   limitations under the License.
+  ~
+  -->
+<configuration scan="true">
+    <conversionRule conversionWord="clr" 
converterClass="org.springframework.boot.logging.logback.ColorConverter" />
+    <conversionRule conversionWord="wex" 
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"
 />
+
+    <property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} 
[%thread] %-5level %logger{36} -
+                %msg%n"/>
+
+    <springProperty scope="context" name="application_name" 
source="spring.application.name"/>
+    <!--<springProperty scope="context" name="application_version" 
source="info.version"/>
+    <springProperty scope="context" name="environment" 
source="spring.profiles.active"/>-->
+
+    <jmxConfigurator/>
+
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} -
+                %msg%n</pattern>
+            <charset>utf8</charset>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="CONSOLE" />
+    </root>
+
+</configuration>
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
index 96ab667..6b645ad 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-consumer.properties
@@ -6,17 +6,18 @@
 #   The ASF licenses this file to You under the Apache License, Version 2.0
 #   (the "License"); you may not use this file except in compliance with
 #   the License.  You may obtain a copy of the License at
-#  
+#
 #       http://www.apache.org/licenses/LICENSE-2.0
-#  
+#
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-#  
+#
 #
 
-dubbo.application.name=annotation-consumer
+dubbo.application.name=resilience4jboot2-annotation-consumer
 dubbo.registry.address=zookeeper://127.0.0.1:2181
-dubbo.consumer.timeout=3000
\ No newline at end of file
+dubbo.consumer.timeout=3000
+dubbo.consumer.retries=-1
diff --git 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-provider.properties
 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-provider.properties
index 51fccca..2388cf0 100644
--- 
a/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-provider.properties
+++ 
b/dubbo-samples-resilience4j/dubbo-samples-resilience4j-springboot2/src/main/resources/spring/dubbo-provider.properties
@@ -6,18 +6,19 @@
 #   The ASF licenses this file to You under the Apache License, Version 2.0
 #   (the "License"); you may not use this file except in compliance with
 #   the License.  You may obtain a copy of the License at
-#  
+#
 #       http://www.apache.org/licenses/LICENSE-2.0
-#  
+#
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-#  
+#
 #
 
-dubbo.application.name=annotation-provider
+dubbo.application.name=resilience4jboot2-annotation-provider
 dubbo.registry.address=zookeeper://127.0.0.1:2181
 dubbo.protocol.name=dubbo
-dubbo.protocol.port=20880
\ No newline at end of file
+dubbo.protocol.port=20880
+dubbo.provider.timeout=1000
diff --git a/dubbo-samples-resilience4j/pom.xml 
b/dubbo-samples-resilience4j/pom.xml
index 79b9115..404ea6f 100644
--- a/dubbo-samples-resilience4j/pom.xml
+++ b/dubbo-samples-resilience4j/pom.xml
@@ -32,7 +32,7 @@
     <packaging>pom</packaging>
     <modules>
         <module>dubbo-samples-resilience4j-filter</module>
-        <!--<module>dubbo-samples-resilience4j-springboot2</module>-->
+        <module>dubbo-samples-resilience4j-springboot2</module>
     </modules>
 
     <properties>
diff --git a/dubbo-samples-spring-boot-hystrix/pom.xml 
b/dubbo-samples-spring-boot-hystrix/pom.xml
index 941ccf1..56b5baf 100644
--- a/dubbo-samples-spring-boot-hystrix/pom.xml
+++ b/dubbo-samples-spring-boot-hystrix/pom.xml
@@ -56,6 +56,12 @@
             <version>1.4.4.RELEASE</version>
         </dependency>
 
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>

Reply via email to