Skip to content

Instantly share code, notes, and snippets.

@pallocchi
Last active March 9, 2017 03:42
Show Gist options
  • Save pallocchi/543cb925f9761690fbc7e73501e74783 to your computer and use it in GitHub Desktop.
Save pallocchi/543cb925f9761690fbc7e73501e74783 to your computer and use it in GitHub Desktop.
Using Java 8 lambdas with Netflix Hystrix
public class CommandHelloWorld extends HystrixCommand<String> {
private final String name;
public CommandHelloWorld(String name) {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"))
.andCommandKey(HystrixCommandKey.Factory.asKey("ExampleCommand")))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(5000));
this.name = name;
}
@Override
protected String run() {
return "Hello " + name + "!";
}
@Override
protected String getFallback() {
return "Hello anonymous!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment