WF Reactive System (1)
- Java 8
- IntelliJ IDEA
Part I: Preparation from Template
Create new lagom project from template.
sbt new lagom/lagom-scala.g8
- Import project into IDE.
- Refactor project-name-API to create producer API and IMPL.
- rename folder wfproducer-API.
- Rename module wfproducer-API.
- Change new names in
build.sbtlazy vals and bindings. Note: at this point you can remove lazy vals of stream services API and its implementation created by lagom template.
- Test by runAll. If you’ve done changes correct it’ll run.
Part II: Define a Producer Service API
- Delete stream-api and stream-impl services. Do not forget to remove their references (lazy val) from build.sbt
- Since we’re building a reactive Weather forecast system we’ll handle user events on wf-producer service.
- Rename wfreactiveService Scala class of wf-producer-API service. Take into consideration that a service API is an interface that in scala is declared with a trait, so make sure to rename using IDE’s refactor capabilities in order to keep consistency and find usages on other scala files.
- Extract model from service api implementation.
- Create model package inside api.
- Move class to the new model package.
- Rename class and its companion object to WFMessage.
- Open WFService.
- Change the topic to wfTemperature.
- Change signature of wfTemperature.
- Remove other functions definition.
- Rename greetingsTopic function to wfTopic and its signature.
- Include pathCall to wfTemperature in descriptor.
- Remove the addProperty Kafka part.
- Delete case class GreetingMessageChanged part.
Part III: Define a Producer Service Implementation (impl)
- Producer commands Creation:
- Sealed trait WFCommand
- Create companion objects for commands
- Create Serialized registry. Add all command case classes.
- Create system events:
- (sealed trait) WFEvent
- Create Event Tag (WFEventTag) for Service.
- Add system events case classes to Serialized registry.
- Create WFState
- Add WFState to Serialized registry.
- Modify WfreactiveEntity.
- Rename it to WFEntity.
- Change Initial State
- Implement WFLoader
- Rename it to WFLoader
- override lazy val jsonSerializerRegistry = WFSerializerRegistry
- Implement WFServiceImpl
- Change in application.conf values of Loader
play.application.loader = com.example.wfreactive.impl.WFLoader
(This is a guide, a draft, will be completed with images soon)
Trackbacks / Pingbacks