/rpa-em-ccd-orchestrator

Orchestrator service that will facilitate interactions between CCD, the bundling stitching service, and any services using bundling.

Primary LanguageJavaMIT LicenseMIT

Evidence Management CCD Orchestrator

Build Status codecov License: MIT

CCD Orchestrator is a backend service that facilitates interactions between CCD, the EM Stitching service, and a calling service.

Setup

az login
az acr login --name hmcts --subscription 1c4f0704-a29e-403d-b719-b90c34ef14c9
./gradlew assemble
DOCMOSIS_ACCESS_KEY=xxx docker-compose -f docker-compose-dependencies.yml up --build

Note that unlike other Evidence Management projects the ccd-orchestrator-api is included in the docker-compose-dependencies.yaml and will run via docker for local functional testing. This is to work around an issue with Linux docker container networking.

Tech

It uses:

  • Java8
  • Spring boot
  • Junit, Mockito and SpringBootTest and Powermockito
  • Gradle
  • lombok project - Lombok project

Plugins

Quickstart

#Cloning repo and running though docker
git clone https://github.com/hmcts/rpa-em-ccd-orchestrator.git
cd rpa-em-ccd-orchestrator/
./buildrundm-docker.sh
#Run this script to acquire IDAM credentials required for DM API.
./idam.sh

Swagger UI

To view our REST API go to {HOST}:{PORT}/swagger-ui.html

http://localhost:8080/swagger-ui.html

API Endpoints

A list of our endpoints can be found here

https://hmcts.github.io/reform-api-docs/swagger.html?url=https://hmcts.github.io/reform-api-docs/specs/rpa-em-ccd-orchestrator.json

Automated Bundling Configuration Validation

The bundle configuration files can be validated by executing the validateYaml task:

./gradew validateYaml

Spring Boot application template

Build Status

Purpose

The purpose of this template is to speed up the creation of new Spring applications within HMCTS and help keep the same standards across multpile teams. If you need to create a new app, you can simply use this one as a starting point and build on top of it.

What's inside

The template is a working application with a minimal setup. It contains:

  • application skeleton
  • common plugins and libraries
  • docker setup
  • swagger configuration for api documentation (see how to publish your api documentation to shared repository)
  • code quality tools already set up
  • integration with Travis CI
  • Hystrix circuit breaker enabled
  • Hystrix dashboard
  • MIT license and contribution information

The application exposes health endpoint (http://localhost:4550/health) and metrics endpoint (http://localhost:4550/metrics).

Plugins

The template contains the following plugins:

Building and deploying the application

Building the application

The project uses Gradle as a build tool. It already contains ./gradlew wrapper script, so there's no need to install gradle.

To build the project execute the following command:

  ./gradlew build

Running the application

Create the image of the application by executing the following command:

  ./gradlew installDist

Create docker image:

  docker-compose build

Run the distribution (created in build/install/spring-boot-template directory) by executing the following command:

  docker-compose up

This will start the API container exposing the application's port (set to 4550 in this template app).

In order to test if the application is up, you can call its health endpoint:

  curl http://localhost:4550/health

You should get a response similar to this:

  {"status":"UP","diskSpace":{"status":"UP","total":249644974080,"free":137188298752,"threshold":10485760}}

Alternative script to run application

To skip all the setting up and building, just execute the following command:

./bin/run-in-docker.sh

For more information:

./bin/run-in-docker.sh -h

Script includes bare minimum environment variables necessary to start api instance. Whenever any variable is changed or any other script regarding docker image/container build, the suggested way to ensure all is cleaned up properly is by this command:

docker-compose rm

It clears stopped containers correctly. Might consider removing clutter of images too, especially the ones fiddled with:

docker images

docker image rm <image-id>

There is no need to remove postgres and java or similar core images.

Hystrix

Hystrix is a library that helps you control the interactions between your application and other services by adding latency tolerance and fault tolerance logic. It does this by isolating points of access between the services, stopping cascading failures across them, and providing fallback options. We recommend you to use Hystrix in your application if it calls any services.

Hystrix circuit breaker

This template API has Hystrix Circuit Breaker already enabled. It monitors and manages all the@HystrixCommand or HystrixObservableCommand annotated methods inside @Component or @Service annotated classes.

Hystrix dashboard

When this API is running, you can monitor Hystrix metrics in real time using Hystrix Dashboard. In order to do this, visit http://localhost:4550/hystrix and provide http://localhost:4550/hystrix.stream as the Hystrix event stream URL. Keep in mind that you'll only see data once some of your Hystrix commands have been executed. Otherwise 'Loading...' message will be displayed on the monitoring page.

Other

Hystrix offers much more than Circuit Breaker pattern implementation or command monitoring. Here are some other functionalities it provides:

License

This project is licensed under the MIT License - see the LICENSE file for details