RMS

Repository Manager Service

Carlos Cornejo

eFinancialCareers 2015

Agenda

  • Why RMS?
  • Objectives
  • What is RMS?
  • RMS under the hood
  • Core spring-boot features

Why RMS?

  • This project rises as a necessity of replacing Endeca with Solr
  • Good opportunity to decouple from redesign and create an standalone service that can be independently deployed aside of any BO/FO release aka microservice

Objectives

  • Improve the indexing time required to have updated searchable records.
  • The idea behind Repository Manager service is to wrap the access around a repository of resources via REST offering a full CRUD support
  • Designed a POC to how a reusable component can be adapted to any FO/BO requirements
  • Learn from SMF to create a generic component that can be re-used and extended to any other domain of information. (to support all solr collections accesses)

What is RMS?

  • It's a REST-based microservice using spring boot
  • Why spring boot?
    • spring-based
    • embedded Tomcat/Jetty
    • easy extensible via parent pom multi-modules
    • fully documented
    • large support community

RMS under the hood (I)

base module

  • base module contains all project common building/plugins/dependencies management.

RMS under the hood (II)

api module

  • api module represents the integration with the external world.
  • This is a shared dependency with any client (i.e. redesign).
  • Defines the query domain language that RMS is able to understand and process. 

RMS under the hood (III)

api module

  • This module contains commonalities with any search query and specifics to resource-related query (i.e. profile)
  • This module SHOULD NOT contain any business logic. 
  • This module should mainly contain POJOS and some spring components that are used by the client (BO).
  • In phase 2, the client will contain all possible converters/serializer and this module only will contain POJOS without interfaces to avoid deserialization harness currently handled by gson. 

RMS under the hood (IV)

impl module

  • impl module represents the service tier that abstracts out the access to the search engine via DocumentRepository.
  • Contains all the logic to implement resource accesses via converting resource-related queries to solr-related queries and viceversa
  • In a nutshell it's a wrapper around a search engine (i.e. solr)

RMS under the hood (V)

impl module

  • common package contains all agnostics components about a search query conversion(i.e. facet, keyword, etc.)
  • exception package contains RMS profile-related exceptions
  • service package represents the service tier to access the repository
  • profile.solr package contains all the specifics to profile query conversion

RMS under the hood (VI)

web module

  • web module represents the core of RMS. It's the REST endpoint and also contains all spring-boot harness
  • Its main responsibility is manage the HTTP access to a resource, i.e. profile and the configuration of spring boot

RMS under the hood (VII)

web module

  • controller package contains REST entry points (for profile CRUD access and for RMS-related info)
  • exception contains GlobalExceptionHandler.
  • health contains ping and deep ping implementation.
  • jsonserializers contains temporary gson solution for http converters.
  • Application represents main spring boot class

RMS under the hood (VIII)

web module

  • ProfileController provides REST CRUD API.

RMS under the hood (IX)

solr-config-delivery module

  • solr collection configuration place holder (i.e fullProfilesCollection)
  • Contains a maven harness to be deployed into different environments
  • To be moved out of RMS repository when decided so
  • To deliver fullProfileCollection to solr (from inside solr-config-delivery project):
     
  • By default is deployed to local, to deploy to other environment (qa, qa2, qa3,pilot,prod) (i.e. pilot):
mvn clean install -Psolr-profiles-config-delivery
mvn clean install -Psolr-profiles-config-delivery -Denvironment=pilot

Spring Boot

core features

  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  • Provide opinionated 'starter' POMs to simplify your Maven configuration
  • Absolutely no code generation and no requirement for XML configuration as well as 100% Spring integration

Spring Boot

core

Locating the main application class

  • application class in a root package above other classes/packages

Spring Boot

configuration

Spring Boot favors Java-based configuration

@SpringBootApplication instead of:

  • @Configuration 
  • @EnableAutoConfiguration 
  • @ComponentScan

You can create any spring configuration and/or include/exclude any other configurations as well

Spring Boot

application configuration

Spring Boot

web container

web pom to have reference to:

@RestController annotation (@Controller + @ResponseBody)

  • Spring boot is not primarily meant to be an MVC but a REST endpoint
  • Implicit @ResponseBody

Spring Boot

RMS web configuration

Create @Configuration that extends from WebMvcConfigurerAdapter

override only the methods they're interested in...

Spring Boot

RMS Exception Handler

Using @ControllerAdvice and @ExceptionHandler

Spring Boot

Testing in RMS (I)

  • RMS responsibility is to handle the access to a repository of resources (i.e solr)
  • Under the previous assumption, the only representative integration tests are related to any implementation of SolrServer (http/embedded) and also around RMS as a web container (controller)
  • IT tests should only exist in:
    • impl
    • web

Spring Boot

Testing in RMS (II)

  • RMS building structure allows running different subset of testing resources (unit and integration tests)
  • Unit tests run by:
     
  • Integration tests start with IT*
     
  • RMS doesn't use hamcrest but assertJ instead
mvn clean test
mvn clean verify -Pintegration-test
assertThat(toProfile).isNotNull();
assertThat(toProfile.getId()).isEqualTo(fromDocument.getId());

Spring Boot

Testing inRMS (III)

  • Maven dependency to spring-boot-starter-test
  • @RunWith(SpringJUnit4ClassRunner.class)
  • To run integration spring-boot application tests, load the context using @SpringApplicationConfiguration
  • To run integration spring tests (no web container), load the context using @ContextConfiguration

Running integration test

deck

By Carlos María Cornejo Crespo

deck

  • 846