Skip to content

Instantly share code, notes, and snippets.

@rubykv
Last active June 28, 2021 13:44
Show Gist options
  • Save rubykv/4687c7d8911f6e476ca3eef88057206d to your computer and use it in GitHub Desktop.
Save rubykv/4687c7d8911f6e476ca3eef88057206d to your computer and use it in GitHub Desktop.
Alibaba Sentinel
@Service
public class TestService {
@SentinelResource(value = "getResponseFromFallback", fallback = "fallbackTestMethod", defaultFallback = "defaultFallback")
public String getResponseFromFallback(int i) {
if (i == 0) {
throw new IllegalArgumentException("Error occurred");
}
return "success";
}
public String fallbackTestMethod(int s, Throwable ex) {
return "success from fallback";
}
public String defaultFallback() {
return "success from default fallback";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment