Skip to content

Latest commit

History

296 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Spring Batch Plus

maven central versionbuildcoveragelicense

Spring Batch Plus provides extension features to Spring Batch.

Features

Kotlin DSL

@Bean
funtestJob(batch:BatchDsl): Job= batch {
job("testJob") {
step("jobStep1") {
jobBean("subJob1")
}
step("jobStep2") {
jobBean("subJob2")
}
}
}
@Bean
funsubJob1(batch:BatchDsl, transactionManager:PlatformTransactionManager): Job= batch {
job("subJob1") {
step("testStep1") {
tasklet({ _, _ ->RepeatStatus.FINISHED }, transactionManager)
}
}
}
@Bean
funsubJob2(batch:BatchDsl, transactionManager:PlatformTransactionManager): Job= batch {
job("subJob2") {
step("testStep2") {
tasklet({ _, _ ->RepeatStatus.FINISHED }, transactionManager)
}
}
}

Single class reader-processor-writer

  • ItemStreamFluxReaderProcessorWriter
  • ItemStreamIterableReaderProcessorWriter
  • ItemStreamIterableReaderProcessorWriter
  • ItemStreamSimpleReaderProcessorWriter
// single class
@Component
@StepScope
classSampleTasklet : ItemStreamFluxReaderProcessorWriter<Int, String> {
privatevar count =0overridefunreadFlux(executionContext:ExecutionContext): Flux<outInt> {
returnFlux.generate { sink ->if (count <20) {
sink.next(count)
++count
} else {
sink.complete()
}
}
}
overridefunprocess(item:Int): String? {
return"'$item'"
}
overridefunwrite(chunk:Chunk<String>) {
println(chunk.items)
}
}
// usage
@Bean
funtestJob(
sampleTasklet:SampleTasklet,
batch:BatchDsl,
): Job= batch {
job("testJob") {
step("testStep") {
chunk<Int, String>(3, ResourcelessTransactionManager()) {
reader(sampleTasklet.asItemStreamReader())
processor(sampleTasklet.asItemProcessor())
writer(sampleTasklet.asItemStreamWriter())
}
}
}
}

Other Useful Classes

  • ClearRunIdIncrementer
  • DeleteMetadataJob

Compatibility

We've tested following versions only. Other versions may not work.

Batch Plus (Latest)BatchBoot StarterKotlinJavaStatusSamples
1.2.x (1.2.0)5.2.x3.4.x ~ 3.5.x1.6 or higher17 or higherMaintainedSamples
1.1.x (1.1.0)5.1.x3.2.x ~ 3.3.x1.5 or higher17 or higherMaintainedSamples
1.0.x (1.0.1)5.0.x3.0.x ~ 3.1.x1.5 or higher17 or higherMaintainedSamples
0.3.x (0.3.1)4.3.x2.4.x ~ 2.7.x1.5 or higher1.8 or higherMaintainedSamples
0.2.x (0.2.0)4.3.x2.4.x ~ 2.7.x1.5 or higher1.8 or higherFreezedSamples
0.1.x (0.1.0)4.3.x2.4.x ~ 2.7.x1.5 or higher1.8 or higherFreezedSamples

Download

Since it provides extension features to spring batch, need to used with spring batch.

Gradle

Kotlin

implementation("org.springframework.boot:spring-boot-starter-batch:${springBootVersion}") // need spring batch
implementation("com.navercorp.spring:spring-boot-starter-batch-plus-kotlin:${springBatchPlusVersion}")

Java

implementation("org.springframework.boot:spring-boot-starter-batch:${springBootVersion}") // need spring batch
implementation("com.navercorp.spring:spring-boot-starter-batch-plus:${springBatchPlusVersion}")

Maven

Kotlin

<!-- need spring batch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<version>{springBootVersion}</version>
</dependency>
<dependency>
<groupId>com.navercorp.spring</groupId>
<artifactId>spring-boot-starter-batch-plus-kotlin</artifactId>
<version>{springBatchPlusVersion}</version>
</dependency>

Java

<!-- need spring batch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<version>{springBootVersion}</version>
</dependency>
<dependency>
<groupId>com.navercorp.spring</groupId>
<artifactId>spring-boot-starter-batch-plus</artifactId>
<version>{springBatchPlusVersion}</version>
</dependency>

User Guide

Build from source

Prerequisites

  • Jdk 17 or higher

Build

  • Clean: ./gradlew clean
  • Check: ./gradlew check
    • Coverage report will be generated in ${project}/build/jacoco/html/index.html
  • Assemble: ./gradlew build
  • Install to local: ./gradlew install
  • Publish: ./gradlew publish --no-parallel

License

 Copyright (c) 2022-present NAVER Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Add useful features to spring batch

Topics

Resources

Code of conduct

Contributing

Stars

130 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages