Quick Start

This Quick Start shows how to install Baratine and create a simple single-page application with Baratine. The JavaScript browser client queries a Baratine echo service using WebSockets or HTTP.

While the single-page application is a main application, Baratine can be used for a wide range of service-oriented tasks:

  • Full single-page applications
  • Active in-memory services replacing flat caches
  • Replication and failover for microservices
  • Local services to solve synchronization and queuing

Although this quick start focuses on Baratine as a server, Baratine can be deployed in several configurations:

  • In a servlet web-app to provide internal services
  • As a Baratine server for microservices, in-memory, failover, and sharding
  • Embedded in any Java VM for internal services


  • Baratine requires Java 1.8 or higher.
  • For OpenSSL and JNI sockets, Baratine requires Linux, Mac OS X, or any other Unix flavor.

Quickstart with Maven Archetype

The Baratine Maven archetype creates a skeleton directory with a stub echo service, which can be useful when starting an application.

$ mvn archetype:generate \
      -DarchetypeGroupId=io.baratine \
      -DarchetypeArtifactId=baratine-maven-archetype \
      -DarchetypeVersion=0.10.3 \
      -DgroupId=echo \
      -Dpackage=echo \
      -DartifactId=pod \

The archetype example is an echo service. It can be built and executed as follows:

$ mvn package baratine:run

The baratine> is a Baratine shell prompt. Once you are done, you can type exit to exit.

The single-page example can be browsed at http://localhost:8085.

Installing Baratine

Download Baratine from http://baratine.io/download and extract it to any directory.

The executable is in bin/baratine and the library is lib/baratine.jar.

Running Baratine

Baratine start and deploy start a Baratine server and deploy an application.

$ baratine start
Baratine/0.10.3 start with watchdog at
Baratine/0.10.3 launching watchdog at
  starting *:8085 (cluster-8085)

By default, Baratine uses /tmp/baratine for its work directories and its logs.

Use deploy to deploy an application.

$ baratine deploy examples/hello.jar
  deployed hello.jar to bfs:///config/pods/50-pod.cf

Use shutdown to shut down a Baratine server.

Maven repository

Baratine is also available via Maven for developing Baratine services and embedding:




Service Source Code

Application services use Java interfaces and implementations. Baratine will create a service to manage the threading, inbox queue, and any HTTP REST or WebSocket interfaces.


import io.baratine.core.Result;

public interface EchoService
  void echo(String message, Result<String> result);


import io.baratine.core.Service;
import io.baratine.core.Result;

public class EchoServiceImpl implements EchoService
  public void echo(String message, Result<String> result)


<script src="baratine-js.js"></script>

function execute()
  var client = new Jamp.BaratineClient("http://localhost:8085/s/pod");

  client.query("/echo", "echo", ["Hello World"], function (data)
    var out = document.getElementById("output");

    out.innerText = data;

Servlet Web-App Deployment

To deploy to a servlet web-app, add the compiled hello.jar and baratine.jar to the web-apps WEB-INF/lib directory:

  • WEB-INF/lib/hello.jar
  • WEB-INF/lib/baratine.jar

When the web-app starts, Baratine will scan for @Service classes, register them with the manager, and if they are public, make them available for REST, JSON-RPC, or WebSocket calls.

Programmatic service registration is also available. See the hello, world example for more details.

Embedded Deployment

Embedding Baratine requires baratine.jar and code to programmatically create the ServiceManager and register services.

The registration looks like the following:

  ServiceManager manager = ServiceManager.newManager().build();

         .service(new EchoServiceImpl())

 EchoService echo = manager.lookup("/echo")

After QuickStart




Examples on GitHub:

Client libraries on GitHub: