Hystrix的HelloWorld

王守钰 2020-05-16 20:05:08

入门

pom引入

<!-- hystrix -->
<dependency>
	<groupId>com.netflix.hystrix</groupId>
	<artifactId>hystrix-core</artifactId>
	<version>1.5.18</version>
</dependency>

HelloWorld

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * @author 王守钰
 * @program quan
 * @date 2020年05月15日 18:07
 * @description: Hystrix第一个demo
 */
public class HelloWorldCommand extends HystrixCommand<String> {


    protected HelloWorldCommand() {
        super(HystrixCommandGroupKey.Factory.asKey("HelloWorldGroup"));
    }

    @Override
    protected String run() throws Exception {
        return "HelloWorld";
    }
}