Overview

Persister service provides a framework to persist data in transactional fashion with low latency based on a config file. Removes repetitive and time consuming persistence code from other services.

Pre-requisites

Before you proceed with the documentation, make sure the following pre-requisites are met -

Key Functionalities

Configuration Details

Persister uses configuration file to persist data. The key variables are described below:

serviceMaps:
 serviceName: student-management-service
 mappings:
 - version: 1.0
   description: Persists student details in studentinfo table
   fromTopic: save-student-info
   isTransaction: true
   queryMaps:
       - query: INSERT INTO studentinfo( id, name, age, marks) VALUES (?, ?, ?, ?);
         basePath: Students.*
         jsonMaps:
          - jsonPath: $.Students.*.id

          - jsonPath: $.Students.*.name

          - jsonPath: $.Students.*.age

          - jsonPath: $.Students.*.marks

Bulk Persister:

To persist large quantity of data bulk setting in persister can be used. It is mainly used when we migrate data from one system to another. The bulk persister have the following two settings:

Variable Name

Default Value

Description

persister.bulk.enabled

false

Switch to turn on or off the bulk kafka consumer

persister.batch.size

100

The batch size for bulk update

Any kafka topic containing data which has to be bulk persisted should have '-batch' appended at the end of topic name example: save-pt-assessment-batch.

Persister Config Versioning:

Deployment Details

  1. Write configuration as per the requirement. Refer the example given earlier.

  2. In the environment file, mention the file path of configuration under the variable egov.persist.yml.repo.path while mentioning the file path we have to add file:///work-dir/ as prefix. for example: egov.persist.yml.repo.path = file:///work-dir/configs/egov-persister/abc-persister.yml. If there are multiple file separate it with comma (,) .

  3. Deploy latest version of egov-persister service and push data on kafka topic specified in config to persist it in DB.

Integration 

Integration Scope

The persister configuration can be used by any module to store records in particular table of database.

Integration Benefits

Steps to Integration

  1. Write configuration as per your requirement. Structure of the config file is explained above in the same document.

  2. Check-in the config file to a remote location preferably github.

  3. Provide the absolute path of the checked-in file to DevOps, to add it to the file-read path of egov-persister. The file will be added to egov-persister's environment manifest file for it to be read at start-up of the application.

  4. Run the egov-persister app and push data on kafka topic specified in config to persist it in DB