SlideShare a Scribd company logo
What’s new in Spring Batch 4.3?
Mahmoud Ben Hassine
September 2–3, 2020
springone.io
Safe Harbor Statement
The following is intended to outline the general direction of VMware's offerings. It is intended for information purposes only and may not be incorporated
into any contract. Any information regarding pre-release of VMware offerings, future updates or other planned modifications is subject to ongoing
evaluation by VMware and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to
deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding VMware's offerings. These purchasing
decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for
VMware's offerings in this presentation remain at the sole discretion of VMware. VMware has no obligation to update forward looking information in this
presentation.
2
About me
3
• Principal Software Engineer at VMware
• Spring Batch Co-Lead
• Open Source enthusiast
Github: @benas
Twitter: @b_e_n_a_s
Mahmoud Ben Hassine
Agenda
4
• Current status
• What’s new in Spring Batch 4.3?
• New features
• Performance improvements
• Dependencies updates
• Deprecations and technical debt
• What’s next?
• Q+A
Current status
(Sep 2020)
History of Spring Batch (1/2)
6
• Step scope
• Chunk-oriented processing
• Remote chunking/partitioning
• Java 5
• Spring Framework 3
v2.0
Apr 11, 2009
• Initial APIs
• Item-oriented processing
• XML configuration
• Java 1.4
• Spring Framework 2.5
• Job scope
• JSR-352 support
• SQLite support
• Spring Batch Integration
• Spring Boot support
• Builders for readers
• Builders for writers
• Java 8
• Spring Framework 5
v3.0
May 22, 2014
v1.0
Mar 28, 2008
v4.0
Dec 1, 2017
History of Spring Batch (2/2)
7
• @SpringBatchTest annotation
• @EnableBatchIntegration
annotation
• JSR 380 Bean Validation support
• Json reader/writer
• JSR 305 support
v4.1
Oct 29, 2018
• Apache Avro support
• Apache Kafka support
• Micrometer support
• Performance improvements
• Java 14 records support
• GraalVM support
• Kafka support refinement
• Performance improvements
• Deprecations
• Builders for readers
• Builders for writers
• Java 8
• Spring Framework 5
v4.3
Oct XX, 2020
v4.2
Oct 02, 2019
v4.0
Dec 1, 2017
v5.0
XXX XX, 20XX
• Spring Framework 6
• Java XX
• TBD
History of Spring Batch (2/2)
8
• @SpringBatchTest annotation
• @EnableBatchIntegration
annotation
• JSR 380 Bean Validation support
• Json reader/writer
• JSR 305 support
v4.1
Oct 29, 2018
• Apache Avro support
• Apache Kafka support
• Micrometer support
• Performance improvements
• Java 14 records support
• GraalVM support
• Kafka support refinement
• Performance improvements
• Deprecations
• Builders for readers
• Builders for writers
• Java 8
• Spring Framework 5
v4.3
Oct XX, 2020
v4.2
Oct 02, 2019
v4.0
Dec 1, 2017
v5.0
XXX XX, 20XX
• Spring Framework 6
• Java XX
• TBD
What’s new in v4.3?
(currently in M2)
New features
Java 14 records support
11
• Use records as items in chunk-oriented steps
• Leverage Spring Framework support for records
id,name
1,foo
2,bar
persons.csv
FlatFileItemReader<Person> reader = new FlatFileItemReaderBuilder<Person>()
.name("personItemReader")
.resource(new FileSystemResource("persons.csv"))
.delimited()
.names("id", "name")
.targetType(Person.class)
.build();
public class Person {
private int id;
Private String name;
// constructors
// getters and setters
// equals and hashcode
// toString
}
public record Person(int id, String name) {}
GraalVM support
12
• Leverage Spring Framework support for GraalVM
• Spring Batch jobs run correctly on GraalVM
• Reflection
• Proxies
• etc
Faster startup time + Better memory usage
Kafka support refinement
13
• Ability to start reading from a custom offset in a given partition
• Ability to start reading from the offset stored in Kafka
Image source: http://kafka.apache.org/intro
v4.3: read from custom offsetv4.2: read from the beginning
Support for annotation-based job execution
listeners
14
class MyListener implements JobExecutionListener {
@Override
public void beforeJob(JobExecution jobExecution) {
// do something before job execution
}
@Override
public void afterJob(JobExecution jobExecution) {
// do something after job execution
}
}
class MyListener {
@BeforeJob
public void beforeJob(JobExecution jobExecution) {
// do something before job execution
}
@AfterJob
public void afterJob(JobExecution jobExecution) {
// do something after job execution
}
}
v4.2: interface-based listeners v4.3: interface-based + annotation-based
listeners
Add SynchronizedItemStreamWriter
15
@Bean
public StaxEventItemWriter<Person> itemWriter() {
Jaxb2Marshaller marchaller = new Jaxb2Marshaller();
marchaller.setClassesToBeBound(Person.class);
return new StaxEventItemWriterBuilder<Person>()
.name("personItemWriter")
.resource(new FileSystemResource("persons.xml"))
.marshaller(marchaller)
.rootTagName("persons")
.build();
}
Expected output
• Some item writers are not safe to use in a multi-threaded step
(StaxEventItemWriter, JsonItemWriter, etc)
<persons>
<person>
<id>1</id>
<name>foo</name>
</person>
<person>
<id>2</id>
<name>foo</name>
</person>
</persons>
Actual output
<persons>
<name>foo</name>
<person>
<id>1</id>
</person>
<id>2<person>
<name>foo</name>
</id>
</person>
</persons>
Item writer bean
definition
Add SynchronizedItemStreamWriter
16
@Bean
public SynchronizedItemStreamWriter<Person> itemWriter() {
Jaxb2Marshaller marchaller = new Jaxb2Marshaller();
marchaller.setClassesToBeBound(Person.class);
StaxEventItemWriter<Person> personWriter = new StaxEventItemWriterBuilder<Person>()
.name("personItemWriter")
.resource(new FileSystemResource("persons.xml"))
.marshaller(marchaller)
.rootTagName("persons")
.build();
SynchronizedItemStreamWriter<Person> synchronizedPersonWriter = new SynchronizedItemStreamWriter<>();
synchronizedPersonWriter.setDelegate(personWriter);
return synchronizedPersonWriter;
}
• Some item writers are not safe to use in a multi-threaded step
(StaxEventItemWriter, JsonItemWriter, etc)
=> SynchronizedItemStreamWriter to the
rescue!
Other new features
17
• Add JpaNamedQueryProvider
• Add encoding parameter in StaxEventItemReader
• Micrometer support improvements
• Add DataFieldMaxValueJobParametersIncrementer
• etc
https://spring.io/blog/2020/08/13/spring-batch-4-3-0-m2-is-out
https://spring.io/blog/2020/06/26/spring-batch-4-3-0-m1-is-released-now
Performance improvements
for(item in chunk) {
mongoTemplate.save(item);
}
v4.2 (pseudo
code)
BulkOperations bulkOperations = mongoTemplate.bulkOps();
for(item in chunk) {
bulkOperation.add(item);
}
bulkOperations.execute();
v4.3 (pseudo
code)
Use bulk operations in MongoItemWriter
19
https://github.com/benas/spring-batch-lab/tree/master/issues/gh3713
for(item in chunk) {
repository.save(item);
}
v4.2 (pseudo
code)
repository.saveAll(items);
v4.3 (pseudo
code)
Use bulk operations in RepositoryItemWriter
20
https://github.com/benas/spring-batch-lab/tree/master/issues/gh3720
int getStepExecutionCount(JobInstance jobInstance, String stepName) {
int count = 0;
List<JobExecution> jobExecutions = findJobExecutions(jobInstance);
for (JobExecution jobExecution : jobExecutions) {
List<StepExecution> stepExecutions =
findStepExecutions(jobExecution);
count += countStepExecutions(stepExecutions, stepName);
}
return count;
}
v4.2 (pseudo
code)
v4.3 (pseudo
code)
int getStepExecutionCount(JobInstance jobInstance, String stepName) {
String query = “select count(id) from ... where ...”;
return jdbcTemplate.queryForObject(
query,
new Object[] {jobInstance, stepName},
Integer.class);
}
Job/Step start time improvement
21
https://github.com/benas/spring-batch-lab/tree/master/issues/gh3657
Dependencies updates
Dependencies updates
23
• Spring Framework 5.3
• Spring Integration 5.4
• Spring Data 2020.0
• Spring AMQP 2.3.0
• Spring for Apache Kafka 2.6.0
• Micrometer 1.5.3
Deprecations and
technical debt
Deprecations and technical debt
25
• API deprecation in preparation for v5
• Improve build process
• Improve test infrastructure
• Docker-based tests with testcontainers
• Junit 5
• Improve test coverage
• etc
What’s next?
Release plan for 2020+
27
• Spring Batch 4.3.0-RC1 (Sep 16, 2020) and 4.3.0 (Oct, 2020)
• Bug fix releases for Spring Batch v4.2.x (Same EOL as Spring Boot v2.3)
• Bug fix releases for Spring Batch v4.3.x (Same EOL as Spring Boot v2.4)
• Spring Batch v5 (Spring Framework v6)
Thank you!
Q+A
springone.slack.com: #session-whats-new-in-spring-batch
#springone@springon
e

More Related Content

What's hot (20)

PDF
Spring to Image
VMware Tanzu
 
PDF
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
PDF
Spring Cloud Function: Where We Were, Where We Are, and Where We’re Going
VMware Tanzu
 
PDF
Spring: Your Next Java Micro-Framework
VMware Tanzu
 
PDF
Spring Data JDBC: Beyond the Obvious
VMware Tanzu
 
PDF
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
PDF
Microservice With Spring Boot and Spring Cloud
Eberhard Wolff
 
PDF
Introduction to WebMvc.fn
VMware Tanzu
 
PDF
A Series of Fortunate Events: Building an Operator in Java
VMware Tanzu
 
PDF
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Toni Jara
 
PDF
Ingress? That’s So 2020! Introducing the Kubernetes Gateway API
VMware Tanzu
 
PDF
Walking Through Spring Cloud Data Flow
VMware Tanzu
 
PDF
Simplify Cloud Applications using Spring Cloud
Ramnivas Laddad
 
PDF
Spring Native and Spring AOT
VMware Tanzu
 
PPTX
Springboot Microservices
NexThoughts Technologies
 
PDF
You Can Be Cloud Native, Too
VMware Tanzu
 
ODP
Spring cloud for microservices architecture
Igor Khotin
 
PPTX
Micronaut: A new way to build microservices
Luram Archanjo
 
PDF
Debugging Complex Issues in Web Applications
VMware Tanzu
 
PDF
Weaving Through the Mesh: Making Sense of Istio and Overlapping Technologies
VMware Tanzu
 
Spring to Image
VMware Tanzu
 
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
Spring Cloud Function: Where We Were, Where We Are, and Where We’re Going
VMware Tanzu
 
Spring: Your Next Java Micro-Framework
VMware Tanzu
 
Spring Data JDBC: Beyond the Obvious
VMware Tanzu
 
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
Microservice With Spring Boot and Spring Cloud
Eberhard Wolff
 
Introduction to WebMvc.fn
VMware Tanzu
 
A Series of Fortunate Events: Building an Operator in Java
VMware Tanzu
 
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Toni Jara
 
Ingress? That’s So 2020! Introducing the Kubernetes Gateway API
VMware Tanzu
 
Walking Through Spring Cloud Data Flow
VMware Tanzu
 
Simplify Cloud Applications using Spring Cloud
Ramnivas Laddad
 
Spring Native and Spring AOT
VMware Tanzu
 
Springboot Microservices
NexThoughts Technologies
 
You Can Be Cloud Native, Too
VMware Tanzu
 
Spring cloud for microservices architecture
Igor Khotin
 
Micronaut: A new way to build microservices
Luram Archanjo
 
Debugging Complex Issues in Web Applications
VMware Tanzu
 
Weaving Through the Mesh: Making Sense of Istio and Overlapping Technologies
VMware Tanzu
 

Similar to What’s New in Spring Batch? (20)

PDF
Gain Proficiency in Batch Processing with Spring Batch
Inexture Solutions
 
PPT
Spring Batch Introduction
Tadaya Tsuyukubo
 
PPTX
Spring batch
Deepak Kumar
 
PPTX
Spring batch introduction
Alex Fernandez
 
PPTX
Spring batch
Yukti Kaura
 
PDF
Spring Batch Introduction (and Bitbucket Project)
Guillermo Daniel Salazar
 
PDF
Spring Batch in Code - simple DB to DB batch applicaiton
tomi vanek
 
PPTX
Spring batch in action
Mohammed Shoaib
 
PDF
Spring Batch Performance Tuning
Gunnar Hillert
 
PDF
Spring Batch Workshop
lyonjug
 
PDF
Atlanta JUG - Integrating Spring Batch and Spring Integration
Gunnar Hillert
 
PDF
Spring batch overivew
Chanyeong Choi
 
PPTX
Spring batch for large enterprises operations
Ignasi González
 
DOCX
springn batch tutorial
Jadae
 
PDF
Intro to SpringBatch NoSQL 2021
Slobodan Lohja
 
PPTX
Spring batch
nishasowdri
 
PPTX
Spring Batch
Jayasree Perilakkalam
 
PPTX
Batching and Java EE (jdk.io)
Ryan Cuprak
 
PDF
Spring.io
Cédric GILLET
 
ODP
JBUG.be Infinispan
Andries Inzé
 
Gain Proficiency in Batch Processing with Spring Batch
Inexture Solutions
 
Spring Batch Introduction
Tadaya Tsuyukubo
 
Spring batch
Deepak Kumar
 
Spring batch introduction
Alex Fernandez
 
Spring batch
Yukti Kaura
 
Spring Batch Introduction (and Bitbucket Project)
Guillermo Daniel Salazar
 
Spring Batch in Code - simple DB to DB batch applicaiton
tomi vanek
 
Spring batch in action
Mohammed Shoaib
 
Spring Batch Performance Tuning
Gunnar Hillert
 
Spring Batch Workshop
lyonjug
 
Atlanta JUG - Integrating Spring Batch and Spring Integration
Gunnar Hillert
 
Spring batch overivew
Chanyeong Choi
 
Spring batch for large enterprises operations
Ignasi González
 
springn batch tutorial
Jadae
 
Intro to SpringBatch NoSQL 2021
Slobodan Lohja
 
Spring batch
nishasowdri
 
Spring Batch
Jayasree Perilakkalam
 
Batching and Java EE (jdk.io)
Ryan Cuprak
 
Spring.io
Cédric GILLET
 
JBUG.be Infinispan
Andries Inzé
 
Ad

More from VMware Tanzu (20)

PDF
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
PDF
What AI Means For Your Product Strategy And What To Do About It
VMware Tanzu
 
PDF
Make the Right Thing the Obvious Thing at Cardinal Health 2023
VMware Tanzu
 
PPTX
Enhancing DevEx and Simplifying Operations at Scale
VMware Tanzu
 
PDF
Spring Update | July 2023
VMware Tanzu
 
PPTX
Platforms, Platform Engineering, & Platform as a Product
VMware Tanzu
 
PPTX
Building Cloud Ready Apps
VMware Tanzu
 
PDF
Spring Boot 3 And Beyond
VMware Tanzu
 
PDF
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
VMware Tanzu
 
PPTX
tanzu_developer_connect.pptx
VMware Tanzu
 
PDF
Tanzu Virtual Developer Connect Workshop - French
VMware Tanzu
 
PDF
Tanzu Developer Connect Workshop - English
VMware Tanzu
 
PDF
Virtual Developer Connect Workshop - English
VMware Tanzu
 
PDF
Tanzu Developer Connect - French
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
VMware Tanzu
 
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
PDF
SpringOne Tour: The Influential Software Engineer
VMware Tanzu
 
PDF
SpringOne Tour: Domain-Driven Design: Theory vs Practice
VMware Tanzu
 
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
What AI Means For Your Product Strategy And What To Do About It
VMware Tanzu
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
VMware Tanzu
 
Enhancing DevEx and Simplifying Operations at Scale
VMware Tanzu
 
Spring Update | July 2023
VMware Tanzu
 
Platforms, Platform Engineering, & Platform as a Product
VMware Tanzu
 
Building Cloud Ready Apps
VMware Tanzu
 
Spring Boot 3 And Beyond
VMware Tanzu
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
VMware Tanzu
 
tanzu_developer_connect.pptx
VMware Tanzu
 
Tanzu Virtual Developer Connect Workshop - French
VMware Tanzu
 
Tanzu Developer Connect Workshop - English
VMware Tanzu
 
Virtual Developer Connect Workshop - English
VMware Tanzu
 
Tanzu Developer Connect - French
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
VMware Tanzu
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
SpringOne Tour: The Influential Software Engineer
VMware Tanzu
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
VMware Tanzu
 
Ad

Recently uploaded (20)

PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PPTX
Operations Profile SPDX_Update_20250711_Example_05_03.pptx
Shane Coughlan
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
10 Salesforce Consulting Companies in Sydney.pdf
DianApps Technologies
 
PPT
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
How Can Reporting Tools Improve Marketing Performance.pptx
Varsha Nayak
 
PDF
chapter 5.pdf cyber security and Internet of things
PalakSharma980227
 
PDF
ESUG 2025: Pharo 13 and Beyond (Stephane Ducasse)
ESUG
 
PPTX
Lec 2 Compiler, Interpreter, linker, loader.pptx
javidmiakhil63
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PDF
Notification System for Construction Logistics Application
Safe Software
 
PDF
Australian Enterprises Need Project Service Automation
Navision India
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
Instantiations Company Update (ESUG 2025)
ESUG
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Operations Profile SPDX_Update_20250711_Example_05_03.pptx
Shane Coughlan
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
10 Salesforce Consulting Companies in Sydney.pdf
DianApps Technologies
 
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
How Can Reporting Tools Improve Marketing Performance.pptx
Varsha Nayak
 
chapter 5.pdf cyber security and Internet of things
PalakSharma980227
 
ESUG 2025: Pharo 13 and Beyond (Stephane Ducasse)
ESUG
 
Lec 2 Compiler, Interpreter, linker, loader.pptx
javidmiakhil63
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
Notification System for Construction Logistics Application
Safe Software
 
Australian Enterprises Need Project Service Automation
Navision India
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Instantiations Company Update (ESUG 2025)
ESUG
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

What’s New in Spring Batch?

  • 1. What’s new in Spring Batch 4.3? Mahmoud Ben Hassine September 2–3, 2020 springone.io
  • 2. Safe Harbor Statement The following is intended to outline the general direction of VMware's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of VMware offerings, future updates or other planned modifications is subject to ongoing evaluation by VMware and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding VMware's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for VMware's offerings in this presentation remain at the sole discretion of VMware. VMware has no obligation to update forward looking information in this presentation. 2
  • 3. About me 3 • Principal Software Engineer at VMware • Spring Batch Co-Lead • Open Source enthusiast Github: @benas Twitter: @b_e_n_a_s Mahmoud Ben Hassine
  • 4. Agenda 4 • Current status • What’s new in Spring Batch 4.3? • New features • Performance improvements • Dependencies updates • Deprecations and technical debt • What’s next? • Q+A
  • 6. History of Spring Batch (1/2) 6 • Step scope • Chunk-oriented processing • Remote chunking/partitioning • Java 5 • Spring Framework 3 v2.0 Apr 11, 2009 • Initial APIs • Item-oriented processing • XML configuration • Java 1.4 • Spring Framework 2.5 • Job scope • JSR-352 support • SQLite support • Spring Batch Integration • Spring Boot support • Builders for readers • Builders for writers • Java 8 • Spring Framework 5 v3.0 May 22, 2014 v1.0 Mar 28, 2008 v4.0 Dec 1, 2017
  • 7. History of Spring Batch (2/2) 7 • @SpringBatchTest annotation • @EnableBatchIntegration annotation • JSR 380 Bean Validation support • Json reader/writer • JSR 305 support v4.1 Oct 29, 2018 • Apache Avro support • Apache Kafka support • Micrometer support • Performance improvements • Java 14 records support • GraalVM support • Kafka support refinement • Performance improvements • Deprecations • Builders for readers • Builders for writers • Java 8 • Spring Framework 5 v4.3 Oct XX, 2020 v4.2 Oct 02, 2019 v4.0 Dec 1, 2017 v5.0 XXX XX, 20XX • Spring Framework 6 • Java XX • TBD
  • 8. History of Spring Batch (2/2) 8 • @SpringBatchTest annotation • @EnableBatchIntegration annotation • JSR 380 Bean Validation support • Json reader/writer • JSR 305 support v4.1 Oct 29, 2018 • Apache Avro support • Apache Kafka support • Micrometer support • Performance improvements • Java 14 records support • GraalVM support • Kafka support refinement • Performance improvements • Deprecations • Builders for readers • Builders for writers • Java 8 • Spring Framework 5 v4.3 Oct XX, 2020 v4.2 Oct 02, 2019 v4.0 Dec 1, 2017 v5.0 XXX XX, 20XX • Spring Framework 6 • Java XX • TBD
  • 9. What’s new in v4.3? (currently in M2)
  • 11. Java 14 records support 11 • Use records as items in chunk-oriented steps • Leverage Spring Framework support for records id,name 1,foo 2,bar persons.csv FlatFileItemReader<Person> reader = new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new FileSystemResource("persons.csv")) .delimited() .names("id", "name") .targetType(Person.class) .build(); public class Person { private int id; Private String name; // constructors // getters and setters // equals and hashcode // toString } public record Person(int id, String name) {}
  • 12. GraalVM support 12 • Leverage Spring Framework support for GraalVM • Spring Batch jobs run correctly on GraalVM • Reflection • Proxies • etc Faster startup time + Better memory usage
  • 13. Kafka support refinement 13 • Ability to start reading from a custom offset in a given partition • Ability to start reading from the offset stored in Kafka Image source: http://kafka.apache.org/intro v4.3: read from custom offsetv4.2: read from the beginning
  • 14. Support for annotation-based job execution listeners 14 class MyListener implements JobExecutionListener { @Override public void beforeJob(JobExecution jobExecution) { // do something before job execution } @Override public void afterJob(JobExecution jobExecution) { // do something after job execution } } class MyListener { @BeforeJob public void beforeJob(JobExecution jobExecution) { // do something before job execution } @AfterJob public void afterJob(JobExecution jobExecution) { // do something after job execution } } v4.2: interface-based listeners v4.3: interface-based + annotation-based listeners
  • 15. Add SynchronizedItemStreamWriter 15 @Bean public StaxEventItemWriter<Person> itemWriter() { Jaxb2Marshaller marchaller = new Jaxb2Marshaller(); marchaller.setClassesToBeBound(Person.class); return new StaxEventItemWriterBuilder<Person>() .name("personItemWriter") .resource(new FileSystemResource("persons.xml")) .marshaller(marchaller) .rootTagName("persons") .build(); } Expected output • Some item writers are not safe to use in a multi-threaded step (StaxEventItemWriter, JsonItemWriter, etc) <persons> <person> <id>1</id> <name>foo</name> </person> <person> <id>2</id> <name>foo</name> </person> </persons> Actual output <persons> <name>foo</name> <person> <id>1</id> </person> <id>2<person> <name>foo</name> </id> </person> </persons> Item writer bean definition
  • 16. Add SynchronizedItemStreamWriter 16 @Bean public SynchronizedItemStreamWriter<Person> itemWriter() { Jaxb2Marshaller marchaller = new Jaxb2Marshaller(); marchaller.setClassesToBeBound(Person.class); StaxEventItemWriter<Person> personWriter = new StaxEventItemWriterBuilder<Person>() .name("personItemWriter") .resource(new FileSystemResource("persons.xml")) .marshaller(marchaller) .rootTagName("persons") .build(); SynchronizedItemStreamWriter<Person> synchronizedPersonWriter = new SynchronizedItemStreamWriter<>(); synchronizedPersonWriter.setDelegate(personWriter); return synchronizedPersonWriter; } • Some item writers are not safe to use in a multi-threaded step (StaxEventItemWriter, JsonItemWriter, etc) => SynchronizedItemStreamWriter to the rescue!
  • 17. Other new features 17 • Add JpaNamedQueryProvider • Add encoding parameter in StaxEventItemReader • Micrometer support improvements • Add DataFieldMaxValueJobParametersIncrementer • etc https://spring.io/blog/2020/08/13/spring-batch-4-3-0-m2-is-out https://spring.io/blog/2020/06/26/spring-batch-4-3-0-m1-is-released-now
  • 19. for(item in chunk) { mongoTemplate.save(item); } v4.2 (pseudo code) BulkOperations bulkOperations = mongoTemplate.bulkOps(); for(item in chunk) { bulkOperation.add(item); } bulkOperations.execute(); v4.3 (pseudo code) Use bulk operations in MongoItemWriter 19 https://github.com/benas/spring-batch-lab/tree/master/issues/gh3713
  • 20. for(item in chunk) { repository.save(item); } v4.2 (pseudo code) repository.saveAll(items); v4.3 (pseudo code) Use bulk operations in RepositoryItemWriter 20 https://github.com/benas/spring-batch-lab/tree/master/issues/gh3720
  • 21. int getStepExecutionCount(JobInstance jobInstance, String stepName) { int count = 0; List<JobExecution> jobExecutions = findJobExecutions(jobInstance); for (JobExecution jobExecution : jobExecutions) { List<StepExecution> stepExecutions = findStepExecutions(jobExecution); count += countStepExecutions(stepExecutions, stepName); } return count; } v4.2 (pseudo code) v4.3 (pseudo code) int getStepExecutionCount(JobInstance jobInstance, String stepName) { String query = “select count(id) from ... where ...”; return jdbcTemplate.queryForObject( query, new Object[] {jobInstance, stepName}, Integer.class); } Job/Step start time improvement 21 https://github.com/benas/spring-batch-lab/tree/master/issues/gh3657
  • 23. Dependencies updates 23 • Spring Framework 5.3 • Spring Integration 5.4 • Spring Data 2020.0 • Spring AMQP 2.3.0 • Spring for Apache Kafka 2.6.0 • Micrometer 1.5.3
  • 25. Deprecations and technical debt 25 • API deprecation in preparation for v5 • Improve build process • Improve test infrastructure • Docker-based tests with testcontainers • Junit 5 • Improve test coverage • etc
  • 27. Release plan for 2020+ 27 • Spring Batch 4.3.0-RC1 (Sep 16, 2020) and 4.3.0 (Oct, 2020) • Bug fix releases for Spring Batch v4.2.x (Same EOL as Spring Boot v2.3) • Bug fix releases for Spring Batch v4.3.x (Same EOL as Spring Boot v2.4) • Spring Batch v5 (Spring Framework v6)