Skip to content

mukherr/CobolAccountProcessingBatchMigrationToJava

Repository files navigation

Account Processing Batch Job

A Spring Boot / Spring Batch application that migrates a COBOL account processing batch program to Java. It reads fixed-width account records, calculates interest, validates balances, and writes processed output — all modeled after the original COBOL copybook layouts.

Prerequisites

  • Java 17+
  • Maven 3.8+ (or use the included ./mvnw wrapper)

No external database required — uses an embedded H2 instance for the Spring Batch job repository.

Quick Start

./mvnw spring-boot:run

This runs the batch job and exits. There is no web UI — it's a batch processor. Output is written to output/ACCT-OUT.DAT.

How It Works

Input

Fixed-width file at src/main/resources/input/ACCT-IN.DAT (63 chars per line):

Position Field Format Length
1–10 Customer ID PIC 9(10) 10
11–30 Last Name PIC X(20) 20
31–45 First Name PIC X(15) 15
46–59 Balance PIC S9(11)V99 14
60–61 Account Type SA or CH 2
62–63 Status A/AC or C/CL 2

Processing

  1. Closed accounts are skipped (return code SK)
  2. Savings accounts receive interest at the configured rate (default 3.25%)
  3. Checking accounts receive zero interest
  4. Balances below the minimum threshold (default $100) are flagged with return code LB
  5. All other active accounts get return code OK

Output

Fixed-width file at output/ACCT-OUT.DAT (40 chars per line):

Position Field Format Length
1–10 Customer ID PIC 9(10) 10
11–24 New Balance PIC S9(11)V99 14
25–38 Interest PIC S9(11)V99 14
39–40 Return Code OK, LB, or SK 2

Fault Tolerance

  • Malformed input records are skipped (up to 100) and written to output/dead-letter.dat
  • I/O errors cause immediate step failure so the job can be restarted from its checkpoint

Configuration

All settings are in src/main/resources/application.yml:

batch.account.processing:
  interest-rate: 0.0325    # Annual interest rate
  min-balance: 100.00      # Minimum balance threshold
  chunk-size: 500          # Records per transaction chunk

job:
  input.file: classpath:input/ACCT-IN.DAT
  output.file: file:output/ACCT-OUT.DAT
  dead-letter.file: output/dead-letter.dat

Running Tests

./mvnw test

Observability

Actuator endpoints are enabled for health and Prometheus metrics:

  • GET /actuator/health
  • GET /actuator/prometheus
  • GET /actuator/metrics

Batch counters (batch.account.processing.totalRead, totalProcessed, totalSkipped) are registered as Micrometer gauges.

Project Structure

src/main/java/com/example/accountprocessing/
├── batch/          # Job config, reader/writer, processor, skip listener, counters
├── model/          # AccountRecord, AccountOutputRecord, enums
└── service/        # Interest calculation and balance validation

About

A Spec based workflow for migrating a COBOL based Account Processing Batch to Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors