diff --git a/account-service/pom.xml b/account-service/pom.xml
index 3ad2866a75..7c42097ca7 100644
--- a/account-service/pom.xml
+++ b/account-service/pom.xml
@@ -56,6 +56,10 @@
org.springframework.cloud
spring-cloud-starter-bus-amqp
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-hystrix
+
org.springframework.cloud
spring-cloud-netflix-hystrix-stream
diff --git a/account-service/src/main/java/com/piggymetrics/account/AccountApplication.java b/account-service/src/main/java/com/piggymetrics/account/AccountApplication.java
index be45caee82..a3b68aefc9 100644
--- a/account-service/src/main/java/com/piggymetrics/account/AccountApplication.java
+++ b/account-service/src/main/java/com/piggymetrics/account/AccountApplication.java
@@ -2,6 +2,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
@@ -11,6 +12,7 @@
@EnableDiscoveryClient
@EnableOAuth2Client
@EnableFeignClients
+@EnableCircuitBreaker
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AccountApplication {
diff --git a/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClient.java b/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClient.java
index e8de1564c6..7943fb5844 100644
--- a/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClient.java
+++ b/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClient.java
@@ -7,7 +7,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-@FeignClient(name = "statistics-service")
+@FeignClient(name = "statistics-service", fallback = StatisticsServiceClientFallback.class)
public interface StatisticsServiceClient {
@RequestMapping(method = RequestMethod.PUT, value = "/statistics/{accountName}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
diff --git a/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClientFallback.java b/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClientFallback.java
new file mode 100644
index 0000000000..21c916702d
--- /dev/null
+++ b/account-service/src/main/java/com/piggymetrics/account/client/StatisticsServiceClientFallback.java
@@ -0,0 +1,18 @@
+package com.piggymetrics.account.client;
+
+import com.piggymetrics.account.domain.Account;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author cdov
+ */
+@Component
+public class StatisticsServiceClientFallback implements StatisticsServiceClient {
+ private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsServiceClientFallback.class);
+ @Override
+ public void updateStatistics(String accountName, Account account) {
+ LOGGER.error("Error during update statistics for account: {}", accountName);
+ }
+}
diff --git a/config/src/main/resources/shared/account-service.yml b/config/src/main/resources/shared/account-service.yml
index 55ea99c32e..209425d5ce 100644
--- a/config/src/main/resources/shared/account-service.yml
+++ b/config/src/main/resources/shared/account-service.yml
@@ -20,3 +20,7 @@ server:
servlet:
context-path: /accounts
port: 6000
+
+feign:
+ hystrix:
+ enabled: true
\ No newline at end of file