Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naver/spring-batch-plus
Add useful features to spring batch
https://github.com/naver/spring-batch-plus
dsl java kotlin kotlin-dsl spring-batch
Last synced: 3 days ago
JSON representation
Add useful features to spring batch
- Host: GitHub
- URL: https://github.com/naver/spring-batch-plus
- Owner: naver
- License: apache-2.0
- Created: 2022-10-27T02:33:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-03T14:23:23.000Z (3 days ago)
- Last Synced: 2025-02-03T14:41:15.704Z (3 days ago)
- Topics: dsl, java, kotlin, kotlin-dsl, spring-batch
- Language: Kotlin
- Homepage:
- Size: 1 MB
- Stars: 117
- Watchers: 5
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Spring Batch Plus
![maven central version](https://maven-badges.herokuapp.com/maven-central/com.navercorp.spring/spring-batch-plus-kotlin/badge.svg)
[![build](https://github.com/naver/spring-batch-plus/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/naver/spring-batch-plus/actions/workflows/build.yml?query=branch%3Amain)
[![coverage](https://codecov.io/github/naver/spring-batch-plus/branch/main/graph/badge.svg)](https://codecov.io/github/naver/spring-batch-plus)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/naver/spring-batch-plus/blob/main/LICENSE)Spring Batch Plus provides extension features to [Spring Batch](https://github.com/spring-projects/spring-batch).
## Features
### Kotlin DSL
```kotlin
@Bean
fun testJob(batch: BatchDsl): Job = batch {
job("testJob") {
step("jobStep1") {
jobBean("subJob1")
}
step("jobStep2") {
jobBean("subJob2")
}
}
}@Bean
fun subJob1(batch: BatchDsl, transactionManager: PlatformTransactionManager): Job = batch {
job("subJob1") {
step("testStep1") {
tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager)
}
}
}@Bean
fun subJob2(batch: BatchDsl, transactionManager: PlatformTransactionManager): Job = batch {
job("subJob2") {
step("testStep2") {
tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager)
}
}
}
```### Single class reader-processor-writer
- ItemStreamFluxReaderProcessorWriter
- ItemStreamIterableReaderProcessorWriter
- ItemStreamIterableReaderProcessorWriter
- ItemStreamSimpleReaderProcessorWriter```kotlin
// single class
@Component
@StepScope
class SampleTasklet : ItemStreamFluxReaderProcessorWriter {
private var count = 0override fun readFlux(executionContext: ExecutionContext): Flux {
return Flux.generate { sink ->
if (count < 20) {
sink.next(count)
++count
} else {
sink.complete()
}
}
}override fun process(item: Int): String? {
return "'$item'"
}override fun write(chunk: Chunk) {
println(chunk.items)
}
}// usage
@Bean
fun testJob(
sampleTasklet: SampleTasklet,
batch: BatchDsl,
): Job = batch {
job("testJob") {
step("testStep") {
chunk(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) | Batch | Boot Starter | Kotlin | Java | Status | Samples |
|---------------------|-------|---------------|---------------|---------------|------------|--------------------------------------------------------------------------------------------|
| 1.1.x (1.1.0) | 5.1.x | 3.2.x ~ 3.3.x | 1.5 or higher | 17 or higher | Maintained | [Samples](https://github.com/naver/spring-batch-plus/tree/1.1.x/spring-batch-plus-sample) |
| 1.0.x (1.0.1) | 5.0.x | 3.0.x ~ 3.1.x | 1.5 or higher | 17 or higher | Maintained | [Samples](https://github.com/naver/spring-batch-plus/tree/1.0.x/spring-batch-plus-sample) |
| 0.3.x (0.3.1) | 4.3.x | 2.4.x ~ 2.7.x | 1.5 or higher | 1.8 or higher | Maintained | [Samples](https://github.com/naver/spring-batch-plus/tree/0.3.x/spring-batch-plus-sample) |
| 0.2.x (0.2.0) | 4.3.x | 2.4.x ~ 2.7.x | 1.5 or higher | 1.8 or higher | Freezed | [Samples](https://github.com/naver/spring-batch-plus/tree/v0.2.0/spring-batch-plus-sample) |
| 0.1.x (0.1.0) | 4.3.x | 2.4.x ~ 2.7.x | 1.5 or higher | 1.8 or higher | Freezed | [Samples](https://github.com/naver/spring-batch-plus/tree/v0.1.0/spring-batch-plus-sample) |## Download
Since it provides extension features to spring batch, need to used with [spring batch](https://github.com/spring-projects/spring-batch).
### Gradle
Kotlin
```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
```kotlin
implementation("org.springframework.boot:spring-boot-starter-batch:${springBootVersion}") // need spring batch
implementation("com.navercorp.spring:spring-boot-starter-batch-plus:${springBatchPlusVersion}")
```### Maven
Kotlin
```xml
org.springframework.boot
spring-boot-starter-batch
{springBootVersion}com.navercorp.spring
spring-boot-starter-batch-plus-kotlin
{springBatchPlusVersion}```
Java
```xml
org.springframework.boot
spring-boot-starter-batch
{springBootVersion}com.navercorp.spring
spring-boot-starter-batch-plus
{springBatchPlusVersion}```
## User Guide
- 1.1.x
- [Korean](https://github.com/naver/spring-batch-plus/tree/1.1.x/doc/ko)
- [English](https://github.com/naver/spring-batch-plus/tree/1.1.x/doc/en)
- 1.0.x
- [Korean](https://github.com/naver/spring-batch-plus/tree/1.0.x/doc/ko)
- [English](https://github.com/naver/spring-batch-plus/tree/1.0.x/doc/en)
- 0.3.x
- [Korean](https://github.com/naver/spring-batch-plus/tree/0.3.x/doc/ko)
- [English](https://github.com/naver/spring-batch-plus/tree/0.3.x/doc/en)## Build from source
### Prerequisites
- Jdk 17 or higher
- Kotlin 1.5 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 athttp://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.
```