A Spring Batch application that reads customer data from SQL source, transforms it, and sends HTTP requests with XML payload.
- Spring Boot 3.5.3
- Spring Batch
- Spring Data JPA
- JAXB for XML processing
- H2 Database (for development)
- PostgreSQL (for production)
- Kubernetes for deployment
- Java 21
- Maven
- Clone the repository
- Build the application:
mvn clean package - Run the application:
java -jar target/batch-processing-0.0.1-SNAPSHOT.jar
The application will:
- Initialize an in-memory H2 database with sample customer data
- Execute the batch job to process the data
- Send HTTP requests with XML payload to the configured endpoint
- Exit automatically after job completion
The application can be configured through application.properties:
# Database Configuration
spring.datasource.url=jdbc:h2:mem:batchdb
spring.datasource.username=sa
spring.datasource.password=
# Target API endpoint
app.target.url=https://example.com/api/customersThe application includes a Kubernetes CronJob configuration that runs the job once per hour.
- Kubernetes cluster
- Docker registry to store the application image
-
Build the Docker image:
docker build -t batch-processing:latest . -
Push the image to your registry:
docker tag batch-processing:latest your-registry/batch-processing:latest docker push your-registry/batch-processing:latest -
Update the image reference in
k8s-cronjob.yaml -
Create the database credentials secret:
kubectl create secret generic db-credentials \ --from-literal=username=postgres \ --from-literal=password=your-password -
Apply the CronJob configuration:
kubectl apply -f k8s-cronjob.yaml
src/main/java/com/megasoft/batch_processing/model/- Data modelssrc/main/java/com/megasoft/batch_processing/repository/- Database repositoriessrc/main/java/com/megasoft/batch_processing/service/- Services for HTTP requestssrc/main/java/com/megasoft/batch_processing/config/- Batch job configurationsrc/main/java/com/megasoft/batch_processing/BatchProcessingApplication.java- Main application class