Spring Batch Job with Parallel Steps
springboot
138
springbatch
9
Parallel
5
Male avatar

loveprogramming viết ngày 25/04/2021

https://grokonez.com/spring-framework/spring-batch/spring-batch-job-parallel-steps

Spring Batch Job with Parallel Steps

For scaling a Batch Job, Parallel Steps is one solution that bases on the business logic of application. We split the logic business in distinct responsibilities, and each step can be executed in parallelized flow. The tutorial will guide you how to configure parallel steps with Spring Batch.

Related Articles:

I. Technologies for spring batch parallel step tutorial

– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.8.1.RELEASE
– Spring Boot

  • MySQL Database

    II. Overview

    1. Structure of project

    spring batch parallel step structure-of-project

    2. Step to do

  • Create Spring Boot project
  • Add dependencies
  • Config Batch Job DataSource
  • Create a Simple Tasklet Step
  • Create a Job Launch
  • Enable Batch Job
  • Define Spring Batch Job with XML config
  • Run & Check Result

III. Practices

1. Create Spring Boot project

Open Spring Tool Suite, on main menu, choose File->New->Spring Starter Project, input project info. Then press Finish, spring boot project will be created.

2. Add dependencies

Add spring-boot-starter-batch, spring-boot-starter-web, mysql-connector-java

<?xml version="1.0" encoding="UTF-8"?>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-batch</artifactId>
    </dependency>  
    
      <dependency>
           <groupId>mysql</groupId>
           <artifactId>mysql-connector-java</artifactId>
           <scope>runtime</scope>
       </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>                              
</dependencies>

3. Config Batch Job DataSource

Open application.properties, config spring-datasource for batch job repository


spring.datasource.url=jdbc:mysql://localhost:3306/testdb
spring.datasource.username=root
spring.datasource.password=12345
spring.batch.job.enabled=false

https://grokonez.com/spring-framework/spring-batch/spring-batch-job-parallel-steps

Spring Batch Job with Parallel Steps

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

451 bài viết.
79 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 6 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 5 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 5 tháng trước
1 0
Bài viết liên quan
Male avatar
0 0
https://grokonez.com/springframework/springbatch/configurespringbatchsteprestart How to configure Spring Batch Step for restart In How to use Spr...
loveprogramming viết 19 ngày trước
0 0
Male avatar
0 0
https://grokonez.com/javaintegration/activitiparalleltasksjpawithspringbootexample How to create Activiti Parallel Tasks with Spring JPA + Spring ...
loveprogramming viết 15 ngày trước
0 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
451 bài viết.
79 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!