-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/spring batch examples #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 1acac3d
feat(docs): add link to Spring Batch examples in README
igorcampos-dev d574230
feat(spring-batch-examples): add unit tests for AsyncBatchService and…
igorcampos-dev 3be0e6d
feat(spring-batch-examples): add batch size configuration and integra…
igorcampos-dev 59acb52
feat(spring-batch-examples): add unit tests for AsyncBatchServiceImpl…
igorcampos-dev 2806098
feat(spring-batch-examples): implement async file reading with Excel …
igorcampos-dev 8656841
feat(spring-batch-examples): update spring-batch-excel dependency to …
igorcampos-dev 1224604
feat(spring-batch-examples): refactor package structure, update batch…
igorcampos-dev c63d689
feat(spring-batch-examples): separate spring-batch examples in two mo…
igorcampos-dev bda25d4
feat(spring-batch-examples): reorganize imports and enhance test cove…
igorcampos-dev 64eeb5b
feat(spring-batch-examples): add banner files and update version to 1…
igorcampos-dev 936cd49
feat(spring-batch-examples): update README to clarify examples for da…
igorcampos-dev 2aa5f20
feat(spring-batch-examples): add Docker configuration files and CI wo…
igorcampos-dev cddcce6
feat(spring-batch-examples): update CI configuration to reflect new m…
igorcampos-dev 8fb5394
feat(spring-batch-examples): add chunk size configuration to applicat…
igorcampos-dev a3b55e4
fix(spring-batch-examples): correct chunk size property name and upda…
igorcampos-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /mvnw text eol=lf | ||
| *.cmd text eol=crlf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
3 changes: 3 additions & 0 deletions
3
spring-batch-db-examples/.mvn/wrapper/maven-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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** | ||
|
|
||
| --- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.