For the complete documentation index, see llms.txt. This page is also available as Markdown.

Persister

Overview

In DIGIT, the Persister Service is used to store data in the database by listening to messages from Kafka topics.

It needs a configuration file (in YAML) to understand:

  • Which Kafka topic to listen to

  • What data to extract from the Kafka message

  • Where and how to insert/update this data in the database


Configure Persister

1

Add YAML Config in MDMS/Config Repo

  • Go to your MDMS or the config GitHub repo.

  • Use the right branch based on your environment: example: dev, uat, prod, master

  • Add a new file named like this: egov-persister/persister-pgr.yml. This file tells the persister how to save the complaints.

Sample Persister Configuration For CCRS

persister:
  moduleName: PGR

  kafkaTopics:
    - topic: save-pgr-request
      configKey: PGR_SAVE
    - topic: update-pgr-request
      configKey: PGR_UPDATE

  PGR_SAVE:
    - query: INSERT INTO eg_pgr_service (id, tenantid, servicecode, description, status, createdby, createdtime, lastmodifiedby, lastmodifiedtime)
             VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
      basePath: $.service
      jsonMaps:
        - jsonPath: $.service.id
        - jsonPath: $.service.tenantId
        - jsonPath: $.service.serviceCode
        - jsonPath: $.service.description
        - jsonPath: $.service.applicationStatus
        - jsonPath: $.service.auditDetails.createdBy
        - jsonPath: $.service.auditDetails.createdTime
        - jsonPath: $.service.auditDetails.lastModifiedBy
        - jsonPath: $.service.auditDetails.lastModifiedTime

  PGR_UPDATE:
    - query: UPDATE eg_pgr_service SET status = ?, lastmodifiedby = ?, lastmodifiedtime = ? WHERE id = ?
      basePath: $.service
      jsonMaps:
        - jsonPath: $.service.applicationStatus
        - jsonPath: $.service.auditDetails.lastModifiedBy
        - jsonPath: $.service.auditDetails.lastModifiedTime
        - jsonPath: $.service.id

How to read this sample persister configuration:

Term
What it means

moduleName

Logical name (here, PGR)

topic

Kafka topic (like save-pgr-request) that triggers DB action

basePath

Root path in JSON (e.g., $.service) from which data is picked

jsonPath

Specific path in the request JSON to map to a DB column

query

SQL query to insert/update data in the database

2

Restart Persister Service

  • After saving the configuration, run this to reload the updated configuration. Command to run the configuration: kubectl rollout restart deployment <persister-deployment-name> -n <namespace>

  • The service will not read the new configuration file until it's restarted.

3

Validate Configuration

Once the service is restarted:

  • Submit a complaint

  • Check:

    • A message is published on Kafka (e.g., save-pgr-request)

    • The data is stored in the DB (check table eg_pgr_service)

  • If nothing happens:

    • Check that the topic name matches in both the application and the persister YAML

    • Look for logs in the persister pod for errors


Reference


Summary

  • The Persister config ensures that the complaint data is saved automatically when it is created or updated.

  • It works behind the scenes, triggered by Kafka.

  • You configure it using a simple YAML file to define what to save and where.

  • Restart the service after adding or editing the config.

Last updated

Was this helpful?