Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e84fc1c
feat(spring-batch-examples): add base config spring batch examples
igorcampos-dev Oct 4, 2025
1acac3d
feat(docs): add link to Spring Batch examples in README
igorcampos-dev Oct 4, 2025
d574230
feat(spring-batch-examples): add unit tests for AsyncBatchService and…
igorcampos-dev Oct 4, 2025
3be0e6d
feat(spring-batch-examples): add batch size configuration and integra…
igorcampos-dev Oct 4, 2025
59acb52
feat(spring-batch-examples): add unit tests for AsyncBatchServiceImpl…
igorcampos-dev Oct 4, 2025
2806098
feat(spring-batch-examples): implement async file reading with Excel …
igorcampos-dev Oct 12, 2025
8656841
feat(spring-batch-examples): update spring-batch-excel dependency to …
igorcampos-dev Oct 12, 2025
1224604
feat(spring-batch-examples): refactor package structure, update batch…
igorcampos-dev Oct 18, 2025
c63d689
feat(spring-batch-examples): separate spring-batch examples in two mo…
igorcampos-dev Oct 18, 2025
bda25d4
feat(spring-batch-examples): reorganize imports and enhance test cove…
igorcampos-dev Oct 18, 2025
64eeb5b
feat(spring-batch-examples): add banner files and update version to 1…
igorcampos-dev Oct 18, 2025
936cd49
feat(spring-batch-examples): update README to clarify examples for da…
igorcampos-dev Oct 18, 2025
2aa5f20
feat(spring-batch-examples): add Docker configuration files and CI wo…
igorcampos-dev Nov 17, 2025
cddcce6
feat(spring-batch-examples): update CI configuration to reflect new m…
igorcampos-dev Nov 18, 2025
8fb5394
feat(spring-batch-examples): add chunk size configuration to applicat…
igorcampos-dev Nov 18, 2025
a3b55e4
fix(spring-batch-examples): correct chunk size property name and upda…
igorcampos-dev Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/spring-batch-db-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: spring-batch-db-examples CI Build

on:
pull_request:
branches: [master]
paths:
- "spring-batch-db-examples/**"
types:
- opened
- synchronize
- reopened

jobs:

integration-tests:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: spring-batch-db-examples
strategy:
matrix:
distribution: [ 'temurin' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5.0.0
with:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
cache: 'maven'
- name: Build and analyze
run: ./mvnw clean verify

health-check:
name: Health Check on Services
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: true

- name: Extract service names from docker compose
id: services
run: |
echo "services<<EOF" >> $GITHUB_OUTPUT
docker compose -f ./spring-batch-db-examples/compose.yaml config --services >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Start containers with Compose Action
uses: hoverkraft-tech/compose-action@v2.4.0
with:
compose-file: './spring-batch-db-examples/compose.yaml'
services: ${{ steps.services.outputs.services }}
up-flags: '--build'
down-flags: '--volumes'

- name: Wait for containers to initialize
run: sleep 10

- name: Check container health
run: |
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"
68 changes: 68 additions & 0 deletions .github/workflows/spring-batch-file-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: spring-batch-file-examples CI Build

on:
pull_request:
branches: [master]
paths:
- "spring-batch-file-examples/**"
types:
- opened
- synchronize
- reopened

jobs:

integration-tests:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: spring-batch-file-examples
strategy:
matrix:
distribution: [ 'temurin' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5.0.0
with:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
cache: 'maven'
- name: Build and analyze
run: ./mvnw clean verify

health-check:
name: Health Check on Services
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: true

- name: Extract service names from docker compose
id: services
run: |
echo "services<<EOF" >> $GITHUB_OUTPUT
docker compose -f ./spring-batch-file-examples/compose.yaml config --services >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Start containers with Compose Action
uses: hoverkraft-tech/compose-action@v2.4.0
with:
compose-file: './spring-batch-file-examples/compose.yaml'
services: ${{ steps.services.outputs.services }}
up-flags: '--build'
down-flags: '--volumes'

- name: Wait for containers to initialize
run: sleep 10

- name: Check container health
run: |
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Below you will find a summary table of each subproject. For more details, please

| Name | Description |
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [Spring Boot + Spring Batch + Database](./spring-batch-db-examples) | Demonstrates a basic integration between Spring Batch and Databases |
| [Spring Boot + Spring Batch + File](./spring-batch-file-examples) | Demonstrates a basic integration between Spring Batch and Files |
| [Spring Boot + Jasper](./spring-jasper-example) | Demonstrates a basic integration between Spring Boot and Jasper. |
| [Spring Boot + Kafka](./spring-kafka-example) | Demonstrates a basic integration between Spring Boot and Apache Kafka. |
| [Spring Boot + Keycloak](./spring-keycloak-example) | Demonstrates a basic integration between Spring Boot and Keycloak. |
Expand Down
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<module>spring-keycloak-example</module>
<module>spring-jasper-example</module>
<module>spring-oracle-example</module>
<module>spring-batch-file-examples</module>
<module>spring-batch-db-examples</module>
</modules>

</project>
</project>
62 changes: 62 additions & 0 deletions spring-batch-db-examples/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.DS_Store
**/.classpath
**/.dockerignore
**/.env
**/.factorypath
**/.git
**/.gitignore
**/.idea
**/.project
**/.sts4-cache
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/secrets.dev.yaml
**/values.dev.yaml
**/vendor
LICENSE
README.md
**/*.class
**/*.iml
**/*.ipr
**/*.iws
**/*.log
**/.apt_generated
**/.gradle
**/.gradletasknamecache
**/.nb-gradle
**/.springBeans
**/build
**/dist
**/gradle-app.setting
**/nbbuild
**/nbdist
**/nbproject/private
**/target
*.ctxt
.mtj.tmp
.mvn/timing.properties
buildNumber.properties
dependency-reduced-pom.xml
hs_err_pid*
pom.xml.next
pom.xml.releaseBackup
pom.xml.tag
pom.xml.versionsBackup
release.properties
replay_pid*
2 changes: 2 additions & 0 deletions spring-batch-db-examples/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
30 changes: 30 additions & 0 deletions spring-batch-db-examples/.github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI Build

on:
push:
branches:
- "**"

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
distribution: [ 'temurin' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v5

- name: Setup Java 21
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
cache: 'maven'

- name: Grant execute permission for mvnw
run: chmod +x mvnw

- name: Build with Maven
run: ./mvnw clean verify
32 changes: 32 additions & 0 deletions spring-batch-db-examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
47 changes: 47 additions & 0 deletions spring-batch-db-examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM eclipse-temurin:21-jdk-jammy as deps

WORKDIR /build

COPY --chmod=0755 mvnw mvnw
COPY .mvn/ .mvn/

RUN --mount=type=bind,source=pom.xml,target=pom.xml \
--mount=type=cache,target=/root/.m2 ./mvnw dependency:go-offline -DskipTests

FROM deps as package

WORKDIR /build

COPY ./src src/
RUN --mount=type=bind,source=pom.xml,target=pom.xml \
--mount=type=cache,target=/root/.m2 \
./mvnw package -DskipTests && \
mv target/$(./mvnw help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout).jar target/app.jar

FROM package as extract

WORKDIR /build

RUN java -Djarmode=layertools -jar target/app.jar extract --destination target/extracted

FROM eclipse-temurin:21-jre-jammy AS final

ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser

COPY --from=extract build/target/extracted/dependencies/ ./
COPY --from=extract build/target/extracted/spring-boot-loader/ ./
COPY --from=extract build/target/extracted/snapshot-dependencies/ ./
COPY --from=extract build/target/extracted/application/ ./

EXPOSE 8082

ENTRYPOINT [ "java", "org.springframework.boot.loader.launch.JarLauncher" ]
30 changes: 30 additions & 0 deletions spring-batch-db-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Spring Batch Examples | DB And Async

This project is a **Spring Boot** application demonstrating a **fully asynchronous Spring Batch job**, designed with a focus on **performance** and **scalability**.

---

## 🚀 Overview

The example showcases how to configure and run an **asynchronous Spring Batch job** that processes a large dataset efficiently.
The job reads **10,000 records** from a database table, simulating item processing by printing
`"item processed"` for each entry.

---

## ⚙️ How It Works

- The job leverages Spring Batch’s asynchronous capabilities to read and process data concurrently.
- An **H2 in-memory database** is used to store the sample data.
- The asynchronous behavior is enabled through a specific Spring profile.

---

## 🧩 Technologies Used

- **Java 21**
- **Spring Batch**
- **Spring Boot**
- **H2 Database**

---
22 changes: 22 additions & 0 deletions spring-batch-db-examples/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:

app:
container_name: app
build:
context: .
ports:
- "8082:8082"
environment:
SERVER_PORT: "8082"
SPRING_DATASOURCE_URL: "jdbc:h2:mem:db"
SPRING_DATASOURCE_DRIVER_CLASS_NAME: "org.h2.Driver"
SPRING_DATASOURCE_USERNAME: "sa"
SPRING_DATASOURCE_PASSWORD: ""
SPRING_JPA_HIBERNATE_DDL_AUTO: "create-drop"
SPRING_H2_CONSOLE_ENABLED: "true"
SPRING_H2_CONSOLE_PATH: "/h2-console"
SPRING_BATCH_INITIALIZE_SCHEMA: "always"
SPRING_BATCH_JOB_ENABLED: "false"
SPRING_BATCH_CHUNK_SIZE: "1000"
SPRING_BATCH_BATCH_SIZE: "1000"
SPRING_PROFILES_ACTIVE: "prd"
Loading