WF Reactive System (2)


In previous post (available here.) we gave a try to Lagom and reactive microservices. We started by creating a sample Weather forecast App with three reactive microservices. Starting by the preparation and setup of tools needed, and the creation of service API and its implementation for the producer service that will deal with request that User will generate from a future UI (We’ll have the chance of play with Play framework).

In this  part, we’ll create a consumer API and its implementation.

Part IV: Consumer API

  1. Open the project in the IDE and create a copy of the producer module and rename it as wf-consumer-api.
  2. Add this module to build.sbt.
  3. Go to model and refactor (rename):
    1. WFMessage to WeatherForecasting.
  4. Modify the Service API:
    1. Remove topic
    2. Change descriptor name to “wfconsumer”.
    3. Define functions to:
      1. Get Top Ten Weather Forecasts.
      2. Get one (the first) Weather Forecast. (findOneWFData)
      3. Get the latest Weather Forecast. (latestWF)
    4. Define the rest endpoints URI in descriptor to our consumer.
      1. Get for (findTopTenWFData)
      2. Get for (latestWF)
      3. Get for (latestWF)
    5. Remove the withTopics and withAutoAcl options of descriptor.

Part V: Implementing the Consumer Services

  1. Create model package and create the case class WeatherForecasting.
  2. Create companion object for Json serialization format.
  3. Modify the consumer’s WFCommand
    1. Extend ReplyType[T] (previously [Done])
    2. Create SaveNewWF case class and its companion object.
    3. Delete WF case class and its companion object.
    4. Rename WFSerializerRegistry to WFConsumerSerializerRegistry
    5. Add class to WFSerializerRegistry.
    6. EventTag does not require modification.
    7. Modify WFEvent. Refactor WFChanged to WFSaved and change its signature to receive a WeatherForecast object as parameter.
    8. Remove onReadOnlyCommand
    9. In onEvent change case and add message for detail of message.
    10. Modify WFEntity to implement saving messages to handle onCommand and on Event operations for all WFEvents. It is very important to note that this Entity manages components of CQRS/ES architecture.
    11. Modify WFLoader.
      1. Rename it to WFConsumerLoader
      2. Override load and loadDEvMode.
      3. Change abstract class WFConsumerApplication
      4. Add lazy vals for binding WFService client wfService and message repository (WFRepository).
      5. Override jsonSerializerRegistry.
      6. Add persistentEntityRegistry
      7. Add readSide.register(wire[WFEventProcessor])
    12. Implement WFRepository.
      1. Create package repositories.
      2. Create private [impl] class WFRepository its constructor receives CassandraSession.
      3. Implement method for data fetching according to rest endpoints:
        1. fetchWFData: to retrieve 10 elements
        2. fetchOneWFData: to retrieve one (first) register.
    13. Implement Consumer Service
      1. Create class WFConsumerServiceImpl.
      2. Override findTopTenWFData and findOneWFData
    14. change Loader in resources/application.conf
    15. Add binds to build.sbt.

In the next post, we’ll create a simple frontend for our Reactive System.

About martincx

| Trabajo con Computadores (Y personas) | Ancient Alien Theorist (?)| Madman | Internet | Libros | Con una lista interminable de cosas por hacer, pero completada de a poco. Follow me on twitter.com @martincx

Trackbacks / Pingbacks

  1. Reactive System (and 3) | El Blog de Martín |x| - agosto 20, 2018

Este blog se enriquece con los comentarios, deja acá tu impresión.

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: