Skip to content

hmcts/ccd-message-publisher

Repository files navigation

CCD Message Publisher

Quality Gate Status

Provides the capability to publish CCD message queue candidates to Azure Service Bus on a schedule.

Getting Started

Please note that this microservice is also available within ccd-docker.

Prerequisites

Building and deploying the application

Building the application

The project uses Gradle as a build tool. It already contains a ./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 assemble

Create docker image:

  docker-compose build

Run the distribution (created in the build/libs directory) by executing the following command:

  docker-compose up

This will start the API container exposing the application's port (4456).

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

  curl http://localhost:4456/health

You should get a response similar to this:

  {"status":"UP","components":{"db":{"status":"UP","details":{"database":"PostgreSQL","validationQuery":"isValid()"}},"diskSpace":{"status":"UP","details":{"total":47111729152,"free":3854127104,"threshold":10485760,"exists":true}},"jms":{"status":"UP","details":{"provider":"ActiveMQ"}},"ping":{"status":"UP"},"refreshScope":{"status":"UP"}}}

Alternative script to run application

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

  ./bin/run-in-docker.sh -c -i

For more information:

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

Azure Service Bus & Local Testing

There is currently no Azure Service Bus emulator available for local/offline testing, and therefore the CCD Message Publisher provides an alternative option through an embedded ActiveMQ instance. This is possible due to both Azure Service Bus and ActiveMQ support for the AMQP 1.0 protocol.

ActiveMQ

By default the CCD Message Publisher is configured to start in "dev" mode with ActiveMQ enabled when run locally.

ActiveMQ information, including details on published messages, can be accessed via the Hawtio Management Console UI at http://localhost:4456/hawtio.

Note that the ActiveMQ menu option on Hawtio will only show up once the first message has been published, and data will not persist across restarts. This is meant for dev/test purposes only and ActiveMQ and the Hawtio console are disabled in production.

Azure Service Bus

To enable publishing to an Azure Service Bus destination:

  1. Comment the SPRING_PROFILES_ACTIVE environment variable in the docker-compose.yml
  2. Set the Azure Service Bus connection string in the SERVICE_BUS_CONNECTION_STRING environment variable
  3. Set the destination in the CCD_CASE_EVENTS_DESTINATION environment variable - this can be either a topic or a queue
  4. Restart the application

Developing

Unit tests

To run all unit tests execute the following command:

  ./gradlew test

Integration tests

To run all integration tests execute the following command:

  ./gradlew integration

Code quality checks

We use Checkstyle. To run all local checks execute the following command:

  ./gradlew check

Additionally, SonarQube analyses are performed on all remote code.

License

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