Why Lagom?

In the previous chapter, we discussed the benefits and downsides of a microservices-based approach. We named the main architectural properties of microservices such as autonomy, isolation, and data ownership. We also noted that, compared to the traditional monolithic approach, microservices reduce the complexity of a single service but the complexity of the system as a whole does not disappear. In a sense, it just moves from the internals of a single microservice into the space between them. We looked at the implementation of the shop as a RESTful microservice, and we admitted that we would avoid this additional complexity by focusing on a single service.

As we worked through the Akka-based solution, we also chose the proper database to store events as well as defining and applying migrations to have a proper database schema. The choice of the configuration mechanism was predetermined by Akka but we still had to read and verify the configuration manually. We also needed to decide how to pass dependencies as we constructed runnable applications and properly implemented this passing.

The Lagom framework builds on top of a few existing technologies and utilizes the "convention over configuration" approach to reduce the burden of these repetitive mechanical tasks and to deliver some additional functionality specific to the microservice systems. It does so by providing a kind of "template" for projects.

The preconfigured features include the following:

  • Use of event sourcing as a mechanism for distributed persistence. The recommended database is Apache Cassandra because of its exceptional scalability and natural support for the read side of the CQRS principle.
  • Support for asynchronous communications by making use of reactive streams with Akka Streams as an implementation and message-passing style with Apache Kafka as a broker.
  • Transparent support for different communication protocols, which allows you to abstract complex API calls behind simple method calls.
  • Expressive-service-description DSL, which allows you to define APIs in a flexible and concise way.
  • Dynamic scalability with Akka Cluster.
  • A choice of dependency injection frameworks to wire the application at compile or runtime.
  • Development mode with hot code reload and an ability to start all services and required infrastructure components, including a special development service registry and a service gateway with a single command.
  • Default configuration for the infrastructure and preconfigured logging.

Let's see how these features will help us to re-implement our bakery project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.149.238