Update The sample
@@ -27,12 +27,15 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -52,6 +55,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
@EnableDiscoveryClient
@EnableAutoConfiguration
@EnableFeignClients
+@EnableScheduling
+@EnableCaching
public class DubboSpringCloudConsumerBootstrap {
@Reference
@@ -147,6 +152,11 @@ public class DubboSpringCloudConsumerBootstrap {
@Bean
public ApplicationRunner callRunner() {
return arguments -> {
+ callAll();
+ };
+ }
+
+ private void callAll() {
// To call /path-variables
callPathVariables();
@@ -162,8 +172,11 @@ public class DubboSpringCloudConsumerBootstrap {
// To call /request/body/map
callRequestBodyMap();
+ }
- };
+ @Scheduled(fixedDelay = 10 * 1000L)
+ public void onScheduled() {
+ callAll();
}
private void callPathVariables() {
