DIGIT Docs
v2.3
  • DIGIT Knowledge Base
  • Local Governance
v2.3
  • Introducing Public Finance Management (iFIX)
    • Strategy & Approach
  • Platform
    • Release Notes
      • iFIX Core Release Notes
        • iFIX Core Build Updates
      • iFIX Adaptor Release Notes
        • iFIX Adaptor Build Updates
      • Migration to DIGIT Architecture
        • Migration Checklist
        • Migration Steps - iFIX
        • Migration Steps - Adapter
    • Specification
      • Functional Specifications
      • Technical Specification
        • Information Model
        • APIs
    • Architecture
      • Technology
    • Services
    • Roadmap
    • Source Code
    • Setup
      • iFIX Service Setup
      • Infrastructure Setup
        • Quickstart/Local Setup
        • On AWS
        • On Azure
      • Deploy Services
        • Deploy from your local machine
        • CI/CD
      • API Access Key
    • Configuration
      • Core Service Documents
        • Master Data Setup
          • Domain Services
            • iFIX Core Master Data Service
            • iFIX Core Fiscal Event Service
            • iFIX Core Fiscal Event Post-Processor
        • iFIX Core Data Cleanup
        • iFix Department Entity Service
        • iFix Client Management Service
          • Keycloak Setup
      • Configuring Master Data
      • Promotion Docs
        • Master Data Service Promotion Doc
        • mGramSeva iFIX Adapter
        • Department Entity Service Promotion
        • Fiscal Event And Fiscal Event Post-processor Service Promotion
        • MongoDB Migration
  • Products
    • mGramSeva
      • Functionalities
        • Login and Forgot Password
        • User Roles and Home Screen
        • Create Consumer
        • Search Consumer
        • Edit Consumer
        • View Consumer
        • Billing - Bulk Demand Generation
        • Billing - Metered Connection
        • Revenue Collection - Offline
        • Expenditure - Add Expense
        • Expenditure - Modify Expense
        • User Onboarding - Bulk Upload
        • User Onboarding/Walkthrough
        • Feedback - Post Payment
        • SMS Notifications
        • Home Page Notifications
        • Edit User Profile
        • Bill and Receipt PDF
        • Update Expense Search
        • Bulk Demand Generation for Non Metered
        • Demand/Bill Generation for Metered Connection
        • Household Register
        • Tabular Dashboard - Expense
        • Tabular Dashboard - Collection
        • Download Bills and Receipt
      • Architecture
        • Technology
      • Source Code
      • Documents
        • User Manual
        • Demo video
        • UI Mockups
        • mGramSeva UI
          • Application Permissions & Dependencies
        • Tech User Manual
          • Language Selection
          • Login
          • Update Password FTL
          • Forgot Password
          • Home
          • Edit Profile
          • Change Password
          • Generate Bill
          • Search Connection
          • Consumer Details
            • Create Consumer
            • Update Consumer
          • Expenses
            • Add Expenses
            • Search Expense Bills
            • Modify Expenses
          • Dashboard
            • Monthly Dashboard
            • Collections Dashboard
            • Expenditure Dashboard
          • Collect Payment
          • Consumer Feedback
          • Household Register
          • Bluetooth Thermal Printer Integration
          • Application Structure
        • Application Structure
        • Integration Testing
        • Integration Testing With Github Actions
        • Firebase Analytics Integration
        • Backend Services
          • mGramSeva - Water Services
          • mGramSeva - Water Service Calculator
          • mGramSeva e-Challan Service
          • mGramSeva - User Service
          • mGramSeva - Billing Service
          • mGramSeva - User OTP
          • iFix Adapter Integration Service
          • mGramSeva - Rollout Dashboard
          • mGramSeva Scheduler
          • mGramSeva- Services Re-Indexing
          • mGramSeva Dashboard
    • iFIX Adapter
      • Adapter Service Documents
        • iFIX Adapter Master Data Setup
        • mGramSeva iFIX Adapter Service
        • iFIX Adapter Master Data Service
        • iFix Adapter Services
      • Source Code
      • Installation
        • Local Setup
        • CI/CD
    • iFIX Dashboard
      • Features
      • Architecture
        • Technology
      • Source Code
      • Installation
        • Local Setup
        • CI/CD
      • Documents
        • iFIX Reference Dashboard
          • iFIX Fiscal Event Aggregator
  • Community
    • Ecosystem
      • News and Events
    • PFM Blogs
      • Why PFM Needs Fiscal Information Exchange Standards
      • Re-imagining Digital PFM in India
      • A Transformative Odyssey: The Impact of Smart Payments in Benefit Delivery
    • Discussions
    • Issues
Powered by GitBook

All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.

On this page
  • Overview
  • How CronJob Works
  • Schedulers Available in mGramSeva
  • Configuration
  • USER Creation
  • Deployment

Was this helpful?

Edit on GitHub
Export as PDF
  1. Products
  2. mGramSeva
  3. Documents
  4. Backend Services

mGramSeva Scheduler

PreviousmGramSeva - Rollout DashboardNextmGramSeva- Services Re-Indexing

Last updated 2 years ago

Was this helpful?

Overview

Schedulers are designed to run a particular service at a scheduled time, without triggering manually. We can have multiple schedulers for an application. It will consider the GMT time format only.

How CronJob Works

The python script (name) would read the mdms-read-cronjob json from the mdms service which users CRONJOB user for a token to access mdms service.

Try to identify the API's configured in this mdms with the argument passed while invoking the script.

With the identified configs from the mdms, the script calls the respective API configured there.

Schedulers Available in mGramSeva

Total 7 schedulers are available in the mGramSeva: _schedulerTodaysCollection: This scheduler will run daily to send the day collection amount to the collection employee. _jobscheduler/true: This is to send the notification to the ULB employee when the bulk demand auto-generation is failed.

_schedulermarkexpensebill: This scheduler is used to mark the expense as paid for the paid expenses once for every fortnight. _schedulernewexpenditure: This is used to send the notification once for every fortnight regarding the no of expenditures created. _schedulermonthsummary: This is to send the monthly summary details to the ULB employee. _schedulerpendingcollection: This is to send the total pending amount details to the respective ULB employee user once every fortnight. _jobscheduler/false: This is used to generate the bulk demand automatically once every month.

As we have 7 different schedulers in mGramSeva which will be running in 4 different time slots so we have to configure, all of them run the same python scripts with the different argument which you can see in the file under command -> args

The Time of the scheduler to run should be configured under cron-> schedule option.

Example of failedBulkDemand scheduler.

You can observer

  1. command->args value is failedbulkdemand ( through which python script understand to invoke only api configured in mdms-read-cronjob mdms json file with the name as “failedbulkdemand”

  2. cron->schedule value is “ 30 3 5 * *” which define the time to kick this scheduler i.e at 3.30 on 5th day of every month. As the crontab follows GMT timezone converting this time to IST this jobs run on 9am of on 5th day of every month helps to define the pattern for the schedule cron.

Configuration

Infraops configuration changes

PriorNote: In Devops for every configuration app name will change according to the name of the cron job file given and the schedule will change according to the time set, and argument will be as per job name given in mdms configuration.

labels: app: monthly-cronjob // This name will change based on the cronjob schedular we are using group: mdms-read-cronjob // this is same for all as we are using same python script

cron: schedule: 30 3 4 * * // This depends on the time we need to run the schedular

image: repository: api-cronjob tag: v1

command:

  • python3

  • cronJobAPIConfig.py

args:

  • monthly // This will be the job name which will differ with the requirement of scheduler type.

env: |

  • name: JOB_NAME

valueFrom:

fieldRef:

resources: |

requests: {}

The remaining fields will be the same for all the schedulers.

Monthly: This will run and send the notification to the ULB employee or consumer on the 4th of every month morning at 9 am as per the scheduled time. Fortnightevening: This scheduler will run on the 1st and 15th of every month evening at 6 pm to send the respective notification to the Consumer. Failedbulkdemand: When the bulk demand generation is failed this scheduler will run and share the message to ULB employees to generate demand manually. Dailyevening: This schedular will run daily and send notifications to the collection operator on a daily basis. Here are the links

MDMS Object details and Configuration: {

"jobName": "monthly", // This will change based on the job name

"active": "true", // when it is true schedular will run automatically and when it is false schedular won’t run.

"method": "POST",

"payload": {

"RequestInfo": "{DEFAULT_REQUESTINFO}" // this is common in all the schedulers to send the request info

},

"header": {

"Content-Type": "application/json" // This is one of the common property for all the schedulers

}

}

{

      "jobName": "monthly",

      "active": "true",

      "method": "POST",

      "url": "http://ws-calculator.mgramseva:8080/ws-calculator/waterCalculator/_jobscheduler/false",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "fortnightevening",

      "active": "true",

      "method": "POST",

      "url": "http://ws-services.mgramseva:8080/ws-services/wc/_schedulerpendingcollection",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "monthly",

      "active": "true",

      "method": "POST",

      "url": "http://echallan-services.mgramseva:8080/echallan-services/eChallan/v1/_schedulermonthsummary",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "fortnightevening",

      "active": "true",

      "method": "POST",

      "url": "http://echallan-services.mgramseva:8080/echallan-services/eChallan/v1/_schedulernewexpenditure",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "fortnightevening",

      "active": "true",

      "method": "POST",

      "url": "http://echallan-services.mgramseva:8080/echallan-services/eChallan/v1/_schedulermarkexpensebill",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "failedbulkdemand",

      "active": "true",

      "method": "POST",

      "url": "http://ws-calculator.mgramseva:8080/ws-calculator/waterCalculator/_jobscheduler/true",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    },

    {

      "jobName": "dailyevening",

      "active": "true",

      "method": "POST",

      "url": "http://ws-services.mgramseva:8080/ws-services/wc/_schedulerTodaysCollection",

      "payload": {

        "RequestInfo": "{DEFAULT_REQUESTINFO}"

      },

      "header": {

        "Content-Type": "application/json"

      }

    }

USER Creation

Need to create a user with CRONJOB as name and type as SYSTEM and ROLE as SYSTEM AND EMPLOYEE here is the sample curl to create the user.

curl --location --request POST 'http://localhost:8090/user/users/_createnovalidate'

--header 'Content-Type: application/json'

--data-raw '{
  "RequestInfo": {
    "api_id": "1",
    "ver": "1",
    "ts": null,
    "action": "create",
    "did": "",
    "key": "",
    "msg_id": "",
    "requester_id": "",
    "userInfo": {
      "userName": "XXYY",
      "name": "NAME",
      "gender": "male",
      "mobileNumber": "XXYY",
      "active": true,
      "type": "EMPLOYEE",
      "tenantId": "pb",
      "password": "eGov@123",
      "roles": [
        {
          "code": "SUPERUSER",
          "tenantId": "pb"
        }
      ]
    }
  },
  "User": {
    "userName": "CRONJOB",
    "name": "CRONJOB",
    "gender": "male",
    "mobileNumber": "XXXXXX",
    "active": true,
    "type": "SYSTEM",
    "tenantId": "pb",
    "password": "eGov@123",
    "roles": [
      {
        "code": "SYSTEM",
        "tenantId": "pb"
      }
    ]
  }
}'

Deployment

When you build the cronjob you will get the build id like below. api-cronjob:develop-c0aa08a-2 From this you will take the only id instead of complete name like develop-c0aa08a-2. This will be used as the id for your respective yaml files and will be deployed the same to you required environment to test the cron job. For example :

Mdms-read-cronjob:develop-c0aa08a-2,

fAiledbulkdemand:develop-c0aa08a-2,

Fortnightevening:develop-c0aa08a-2,

monthly:develop-c0aa08a-2 Note: develop-c0aa08a-2 is the common build id for all the files which you are using.

How to run the cronjob manually

Please delete the existing cron jobs if they are already exists with same name.

kubectl delete cronjob mdms-read-cronjob -n mgramseva

Please deploy these builds in QA environments, which are related to cronjob schedulars.

mdms-read-cronjob:develop-c0aa08a-2,failedbulkdemand:develop-c0aa08a-2,fortnightevening:develop-c0aa08a-2,monthly:develop-c0aa08a-2

Steps to test the cron job schedular.

  • kubectl get cronjob -n mgramseva -- to check the list of cron jobs

We will create the job manually to test the messages.

Here are the commands to create the jobs.

Will receive a message for the respective schedular each time we run it.

We can increase the no to test again like failedbulkdemand-manually-1 next it will be failedbulkdemand-manually-2

  • kubectl create job --from=cronjob/failedbulkdemand failedbulkdemand-manually-1 -n mgramseva

  • kubectl create job --from=cronjob/fortnightevening fortnightevening-manually-1 -n mgramseva

  • kubectl create job --from=cronjob/mdms-read-cronjob mdms-read-cronjob-manually-1 -n mgramseva

  • kubectl create job --from=cronjob/monthly monthly-manually-1 -n mgramseva

  • kubectl get job -n mgramseva -- to check the list of jobs

To check the cronjob image

kubectl describe cronjob mdms-read-cronjob -n mgramseva

To delete specific job

kubectl delete jobs mdms-read-cronjob-manually-1 -n mgramseva

fieldPath:

"url": "", // This is the respective service url to call that service as per the scheduler

Here is the Configuration for all the schedulers:

All content on this page by is licensed under a .

metadata.name
Monthly
Failed Bulk Demand
Fortnight Evening
Daily Evening
http://echallan-services.mgramseva:8080/echallan-services/eChallan/v1/_schedulermonthsummary
Click here to see
Crontab.guru - The cron schedule expression editor
Crontab.guru - The cron schedule expression editor
​
eGov Foundation
Creative Commons Attribution 4.0 International License
Creative Commons License