Meet Lagom, the opinionated Microservices framework

It seems like everyone is talking, writing, and thinking about Microservices architecture these days. Still, there is more confusion around what it is, and how to deliver on it, than ever. Truth be told, we have been spoiled by the once-believed almighty Monolith, with its single SQL database, for way too long. Today’s applications are deployed to everything from mobile devices to cloud-based clusters running thousands of multi-core processors. Consumers (human and systems) expect millisecond response times and close to 100% uptime. Traditional Java EE architectures on industry standard middleware simply don’t cut it anymore. We can’t make the horse faster anymore; we need cars for where we are going.

Instead of operating too much of what few people need, the ideal combination of relevant features with as little overhead as possible would be just the right thing. And this is where the recently released Lagom (Swedish for “just right”) places emphasis.

Why Lagom

Lagom is an opinionated framework for guiding JVM developers towards creating Reactive, Microservice-based systems. Lagom’s design rests on the principles outlined by Jonas Bonér in his recent O’Reilly report, Reactive Microservices Architecture: Design Patterns for Distributed Systems.

Lagom is asynchronous by default. All APIs use the asynchronous, non-blocking I/O capabilities of Akka Streams for asynchronous streaming, and the JDK8 CompletionStage API for asynchronous computation.

Lagom favours distributed persistent patterns, in contrast to the traditional centralized database. Event Sourcing (ES) with Command Query Responsibility Segregation (CQRS) is the default way to persist entities with.

The development environment is particularly important in developer productivity, both while developing and maintaining it. Lagom’s expressive service interface declarations let developers quickly define interfaces and immediately start implementing them. In a system with many services, developers should not be spending time updating their own environment to ensure that services are configured to run correctly.

Currently in MVP, Lagom offers Java developers four main features:

  • Service API - this provides a way to declare and implement service interfaces for consumption by clients. For location transparency, clients use stable addresses and discover services through a Service Locator. The Service API supports asynchronous messaging and streaming by default, as well as synchronous request-response calls between services.

  • Persistence API - this provides event-sourced persistent entities for services that store data, with Command Query Responsibility Segregation (CQRS) read-side support for queries. Lagom manages the distribution of persisted entities across a cluster of nodes, enabling sharding and horizontal scaling, with Apache Cassandra as the default database backend.

  • Hot-reload Development Environment - enables developers to run all services along with the supporting Lagom infrastructure with one command. Borrowing from Play Framework, Lagom hot-reloads code changes to services whenever updates are made.

  • Production Readiness - Services can be deployed as they are directly to production using ConductR (part of Reactive Platform’s commercial subscription). In production, Reactive Platform also provides monitoring, deployment orchestration and scaling of Lagom services in a container environment—and no additional infrastructure is needed.

To get to the code snippets, images, videos and more, please continue reading...