Skip to content

Instantly share code, notes, and snippets.

@axiak
Last active January 2, 2016 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axiak/8321523 to your computer and use it in GitHub Desktop.
Save axiak/8321523 to your computer and use it in GitHub Desktop.
public class CommandHelloWorld extends HystrixCommand<String> {
private final String name;
public CommandHelloWorld(String name) {
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
this.name = name;
}
@Override
protected String run() {
// a real example would do work like a network call here
return "Hello " + name + "!";
}
@Override
protected String getFallback() {
return "Hello Failure " + name + "!";
}
}
String s = new CommandHelloWorld("World").execute();
System.out.println(s);
Future<String> fs = new CommandHelloWorld("World").queue();
System.out.println(fs.get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment