I want to add a fallback to my Gateway call in Spring Integration Application.
I have wrapped the call to the gateway in a method with the @HystrixCommand annotation and provided the name of the fallback method in fallbackMethod attribute.
@HystrixCommand(fallbackMethod = "getMockData")
public String gatewayCallGetMessage(String name) {
return serviceGateway.getMessage(name);
}
public String getMockData(String name) {
return "mock data";
}
I have also defined the fallback method in same class.
My Gateway interface is as below,
@MessagingGateway
public interface HystrixServiceGateway {
@Gateway(requestChannel = "get.request.channel", replyChannel = "reply.channel")
String getMessage(String name);
}
I have spring-cloud-starter-hystrix dependency in the classpath/pom.xml. Also, I have @EnableHystrix annotation in my Spring Boot Application class as below.
@EnableHystrix
public class HystrixIntegrationApplication {
...
}
But, when the service is down the gateway call does not go through but the fallback method is not getting executed.
I have shared the code I used to reproduce my issue is as below, https://github.com/sri420/hystrix-integration-demo
If anyone has faced a similar issue and know of a way address it , please let me know.