Last active
January 2, 2016 15:09
-
-
Save axiak/8321523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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