Fork me on GitHub

Spotify Apollo
Operations Manual

A library for writing services that focuses on composability and simplicity, with high performance using modern Java idioms and features.

General Description

Apollo

Apollo is a set of Java libraries that we use at Spotify when writing micro-services. Apollo includes features such as an HTTP server and a URI routing system, making it trivial to implement RESTful services.

Apollo has been used in production at Spotify for a long time. As a part of the work to release version 1.0.0 we are moving the development of Apollo in to the open.

Apollo has three main parts:

  1. apollo-api
  2. apollo-core
  3. apollo-http-service

Apollo API

The apollo-api library defines the interfaces for your request routing and request/reply handlers.

Apollo Core

The apollo-core library manages the lifecycle (loading, starting, and stopping) of your service and defines a powerful module system for adding functionality to an Apollo assembly. You do not usually need to interact directly with apollo-core; think of it merely as “plumbing.”

Apollo HTTP Service

The apollo-http-service library is a standardized assembly of Apollo modules. It incorporates both apollo-api and apollo-core and ties them together with several other useful modules to get a standard api service using HTTP for incoming and outgoing communication.

Getting started

Apollo is distributed as a set of Maven artifacts, which makes it easy to get started no matter the build tool; Maven, Ant + Ivy or Gradle. Below is a very simple but functional service — more extensive examples are available in the GitHub repository.

Use the latest maven artifact
<dependency>
    <groupid>com.spotify</groupid>
    <artifactid>apollo-http-service</artifactid>
    <version>1.0.3</version>
</dependency>
Minimal Apollo Application
public final class App {

    public static void main(String[] args) throws LoadingException {
        HttpService.boot(App::init, "my-app", args);
    }

    static void init(Environment environment) {
        environment.routingEngine()
            .registerAutoRoute(Route.sync("GET", "/", rc -> "hello world"));
    }
 }

Find the JavaDocs here.