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
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 PGR complaints.
Sample Persister Configuration (For PGR)
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:
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
Validate Configuration
Once the service is restarted:
Submit a PGR complaint (via API or UI)
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
DIGIT Dev Docs → MDMS & Persister
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?