Skip to content

Getting started with QBit Microservice Lib

Richard Hightower edited this page Jun 18, 2016 · 27 revisions

If you are new to QBit. It might make more sense to skim the overview. We suggest reading the landing page of the QBit Microservices Lib's wiki for a background on QBit. This will let you see the forrest while the tutorials are inspecting the trees. There is also a lot of documents linked to off of the wiki landing page as well as in the footer section of the tutorials.

Getting started with QBit Microservice Lib Part 1

Mammatus Tech

Home < Part 1 Part 2 > Part 3 >> -- -example code- -qbit docs-

QBit is a reactive programming lib for building microservices - JSON, HTTP, WebSocket, and REST. QBit uses reactive programming to build elastic REST, and WebSockets based cloud friendly, web services. QBit is SOA evolved for mobile and cloud computing. QBit is a small lightweight lib that provides support for ServiceDiscovery, Health, reactive StatService, typed events, and Java idiomatic reactive programming for Microservices.

QBit is small and wicked fast.

QBit is wicked fast

Learn gradle.

Setup gradle build file

group 'qbit-ex'
version '1.0-SNAPSHOT'

apply plugin: 'java'

apply plugin: 'application'

mainClassName = "com.mammatustech.HelloWorldService"

compileJava {
    sourceCompatibility = 1.8

repositories {

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'io.advantageous.qbit:qbit-admin:1.10.0.RELEASE'
    compile 'io.advantageous.qbit:qbit-vertx:1.10.0.RELEASE'

task wrapper(type: Wrapper) {
    gradleVersion = '2.14'

Look for the latest official release here of the QBit Microservice lib.

Java code for hello world QBit

public class HelloWorldService {

    public String hello() {
        return "hello " + System.currentTimeMillis();

    public static void main(final String... args) {
        final ManagedServiceBuilder managedServiceBuilder =

        managedServiceBuilder.getContextMetaBuilder().setTitle("Hello World");

        /* Start the service. */
        managedServiceBuilder.addEndpointService(new HelloWorldService())

        /* Start the admin builder which exposes health end-points and meta data. */

        System.out.println("Servers started");



Run the app.

Run the app

$ gradle run

Hit the app with curl

$ curl http://localhost:8080/root/hello/hello
"hello 1440742489358"

Hit the app a lot with wrk

$ $ wrk -d 5s -t 2 -c 1000 http://localhost:8080/root/hello/hello
Running 5s test @ http://localhost:8080/root/hello/hello
  2 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.61ms    3.63ms 100.14ms   94.50%
    Req/Sec    37.61k     8.21k   44.38k    90.00%
  374118 requests in 5.03s, 32.82MB read
  Socket errors: connect 0, read 913, write 2, timeout 0
Requests/sec:  74415.93
Transfer/sec:      6.53MB

Find out more about wrk.

Find out more about QBit.


You can find more information reading the tutorials and looking at the wiki. If you are new to QBit, please take some time to skim the overview to QBit Microservices. After you skim the overview, look into QBit batteries included microservice lib to get a feel for how QBit supports the full ethos of Microservices Architecture (as it supports monitoring, health checks, service discovery, api gateways, etc.). Check out the introduction to QBit reactive programming model to get a feel for the depth of QBit and how QBit supports coordinating async callbacks. To get a real feel for what it means to be an idiomatic Java lib for microservices read about the Event Bus and Type event bus. Keep in mind that QBit is pluggable and you can plug in additional event busses (Kafka, Aeron, etc.) as well as plugin different protocol parsers (Thrift, Message Pack) or JSON parsers (Jackon, GSON), etc.), but still keep the same idiomatic Java programming model. This is just the start of your QBit journey. There is much to explore.

You can’t perform that action at this time.