Getting Started

David Gross edited this page Mar 1, 2015 · 12 revisions


  1. Getting Binaries
  2. “Hello World!”
  3. Building

Getting Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at

Example for Maven:


and for Ivy:

<dependency org="" name="hystrix-core" rev="x.y.z" />

If you need to download the jars instead of using a build system, create a Maven pom file like this with the desired version:

<?xml version="1.0"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <name>Simple POM to download hystrix-core and dependencies</name>

Then execute:

mvn -f download-hystrix-pom.xml dependency:copy-dependencies

It will download hystrix-core-*.jar and its dependencies into ./target/dependency/.

You need Java 6 or later.

Hello World!

The simplest use of Hystrix is as follows:

public class CommandHelloWorld extends HystrixCommand<String> {

    private final String name;

    public CommandHelloWorld(String name) {
        super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")); = name;

    protected String run() {
        // a real example would do work like a network call here
        return "Hello " + name + "!";

View Source

This command could be used like this:

String s = new CommandHelloWorld("Bob").execute();
Future<String> s = new CommandHelloWorld("Bob").queue();
Observable<String> s = new CommandHelloWorld("Bob").observe();

More examples and information can be found in the How To Use section.

Example source code can be found in the hystrix-examples module.


To checkout the source and build:

$ git clone
$ cd Hystrix/
$ ./gradlew build

To do a clean build:

$ ./gradlew clean build

A build should look like this:

$ ./gradlew build
:hystrix-core:processResources UP-TO-DATE
:hystrix-core:signArchives SKIPPED
:hystrix-core:licenseMain UP-TO-DATE
:hystrix-core:licenseTest UP-TO-DATE
:hystrix-core:processTestResources UP-TO-DATE
:hystrix-examples:processResources UP-TO-DATE
:hystrix-examples:signArchives SKIPPED
:hystrix-examples:licenseMain UP-TO-DATE
:hystrix-examples:licenseTest UP-TO-DATE
:hystrix-examples:processTestResources UP-TO-DATE


Total time: 30.758 secs

On a clean build you will see the unit tests be run and look something like this:

> Building > :hystrix-core:test > 147 tests completed