DEV Community

Cover image for RESTHeart - a Java runtime for microservices
Maurizio Turatti
Maurizio Turatti

Posted on • Updated on

RESTHeart - a Java runtime for microservices

In 2014 we had long realized that both Java application servers and frameworks force people to invest a lot of time in their configuration and maintenance, comparing to what is usually invested in the implementation of actual functionalities.

For these reasons, at our company we started developing an open-source product called RESTHeart, in order to investigate more rational ways to build applications. It was born as a summer experiment and it became an increasingly focused and robust product in the following years.

What RESTHeart actually does, in a minute

RESTHeart is a Java open source runtime for microservices. It leverages MongoDB to provide a instant persistence data API.

  • Instant REST API with MongoDB;
  • Built-in Authentication and Authorization;
  • Elegant Java and Kotlin Framework to extend the API.

RESTHeart is tailored for JVM, Docker and Kubernetes, designed to radically simplify server-side development and deployment.

  • Ready-to-run stateless Microservice;
  • Available as binary and Docker container;
  • Deploy both on Cloud and on-premises.

RESTHeart is a "low code" development platform: you can get most of the mandatory server-side functionalities usually required by any Web and Mobile application with just configuration.

RESTHeart allows to create REST Web Services in minutes: implement a simple Java interface and deploy the web service by copying its JAR file into the plugins directory.

@RegisterPlugin(name = "greeterService", 
    description = "sends a greetings message",
    defaultURI = "/greetings")
public class GreeterService implements JsonService {
    @Override
    public void handle(JsonRequest request, JsonResponse response) {
        if (request.isGet()) {
            var content = new JsonObject();
            content.addProperty("message", "Hello World!");
            response.setContent(content);
        } else {
            response.setStatusCode(400);
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

The main advantage with RESTHeart is that you can immediately write and read data into a MongoDB database using just HTTP. Your JSON will travel untouched from the client to the database and back.

Alt Text

Specifications

  • Written in Java 11
  • Built on top of RedHat’s Undertow non-blocking HTTP server.
  • Uses MongoDB and compatible databases for data persistence.
  • Fully stateless.
  • Can be packaged as a Docker container.
  • Can be easily deployed both on Cloud and on premises.

Main features

RESTHeart unlocks all the capabilities of MongoDB.
It can also connect to Mongo Atlas Cloud, Amazon DocumentDB, Microsoft Azure CosmosDB and Percona Server for MongoDB.

For a complete list of features please go to this page.

Try online

You can try a simple Angular Web application here.

Examples

This repository provides examples on how to extend RESTHeart with Java or Kotlin plugins:

Source code

The full source code is available on GitHub.

Top comments (0)