|
1 | 1 | [[whatsNew]] |
2 | | -= What's New in Spring Batch 5.1 |
| 2 | += What's new in Spring Batch 5.2 |
3 | 3 |
|
4 | | -This section shows the major highlights of Spring Batch 5.1. For the complete list of changes, please refer to the https://github.com/spring-projects/spring-batch/releases[release notes]. |
| 4 | +This section highlights the major changes in Spring Batch 5.2. For the complete list of changes, please refer to the https://github.com/spring-projects/spring-batch/releases[release notes]. |
5 | 5 |
|
6 | | -Spring Batch 5.1 includes the following features: |
| 6 | +Spring Batch 5.2 includes the following features: |
7 | 7 |
|
8 | 8 | * xref:whatsnew.adoc#dependencies-upgrade[Dependencies upgrade] |
9 | | -* xref:whatsnew.adoc#virtual-threads-support[Virtual Threads support] |
10 | | -* xref:whatsnew.adoc#memory-management-improvement-jpaitemwriter[Memory management improvement in the JpaItemWriter] |
11 | | -* xref:whatsnew.adoc#new-synchronized-decorators[New synchronized decorators for item readers and writers] |
12 | | -* xref:whatsnew.adoc#new-cursor-based-mongo-item-reader[New Cursor-based MongoItemReader] |
13 | | -* xref:whatsnew.adoc#bulk-inserts-support-mongo-item-writer[Bulk inserts support in MongoItemWriter] |
14 | | -* xref:whatsnew.adoc#new-item-reader-and-writer-for-redis[New item reader and writer for Redis] |
15 | | -* xref:whatsnew.adoc#automatic-configuration-of-jobregistrybeanpostprocessor[Automatic configuration of JobRegistryBeanPostProcessor] |
16 | | -* xref:whatsnew.adoc#ability-to-start-a-job-flow-with-a-decision[Ability to start a job flow with a decision] |
17 | | -* xref:whatsnew.adoc#ability-to-provide-a-custom-jobkeygenerator[Ability to provide a custom JobKeyGenerator] |
18 | | -* xref:whatsnew.adoc#new-documentation-based-on-antora[New documentation based on Antora] |
19 | | -* xref:whatsnew.adoc#improved-getting-started-experience[Improved Getting Started experience] |
20 | | - |
21 | | -Moreover, this release introduces the following experimental features: |
22 | | - |
23 | | -* xref:whatsnew.adoc#mongodb-job-repository[MongoDB Job Repository] |
24 | | -* xref:whatsnew.adoc#composite-item-reader[Composite Item Reader] |
25 | | -* xref:whatsnew.adoc#new-chunk-oriented-step-implementation[New Chunk-Oriented Step Implementation] |
| 9 | +* xref:whatsnew.adoc#query-hints-support[Query hints support in JPA item readers] |
| 10 | +* xref:whatsnew.adoc#data-class-support[Data class support in JDBC item readers] |
| 11 | +* xref:whatsnew.adoc#configurable-line-separator-in-recursivecollectionlineaggregator[Configurable line separator in RecursiveCollectionLineAggregator] |
| 12 | +* xref:whatsnew.adoc#job-registration-improvements[Job registration improvements] |
26 | 13 |
|
27 | 14 | [[dependencies-upgrade]] |
28 | 15 | == Dependencies upgrade |
29 | 16 |
|
30 | 17 | In this release, the Spring dependencies are upgraded to the following versions: |
31 | 18 |
|
32 | | -* Spring Framework 6.1.0 |
33 | | -* Spring Integration 6.2.0 |
34 | | -* Spring Data 3.2.0 |
35 | | -* Spring LDAP 3.2.0 |
36 | | -* Spring AMQP 3.1.0 |
37 | | -* Spring Kafka 3.1.0 |
38 | | -* Micrometer 1.12.0 |
| 19 | +* Spring Framework 6.2.0 |
| 20 | +* Spring Integration 6.4.0 |
| 21 | +* Spring Data 3.4.0 |
| 22 | +* Spring Retry 2.0.9 |
| 23 | +* Spring LDAP 3.2.7 |
| 24 | +* Spring AMQP 3.2.0 |
| 25 | +* Spring Kafka 3.3.0 |
| 26 | +* Micrometer 1.14.0 |
39 | 27 |
|
40 | | -[[virtual-threads-support]] |
41 | | -== Virtual Threads support |
| 28 | +[[query-hints-support]] |
| 29 | +== Query hints support in JPA item readers |
42 | 30 |
|
43 | | -Embracing JDK 21 LTS is one of the main themes for Spring Batch 5.1, especially the support of |
44 | | -virtual threads from Project Loom. In this release, virtual threads can be used in all areas of the |
45 | | -framework, like running a concurrent step with virtual threads or launching multiple steps in parallel |
46 | | -using virtual threads. |
| 31 | +Up until version 5.1, the JPA cursor and paging item readers did not support query hints (like the fetch size, timeout, etc). |
| 32 | +Users were required to provide a custom query provider in order to specify custom hints. |
47 | 33 |
|
48 | | -Thanks to the well designed separation of concerns in Spring Batch, threads are not managed directly. Thread |
49 | | -management is rather delegated to `TaskExecutor` implementations from Spring Framework. This programming-to-interface |
50 | | -approach allows you to switch between `TaskExecutor` implementations in a transparent and a flexible way. |
| 34 | +In this release, JPA readers and their respective builders were updated to accept query hints when defining the JPA query to use. |
51 | 35 |
|
52 | | -In Spring Framework 6.1, a new `TaskExecutor` implementation based on virtual threads has been introduced, which is the |
53 | | -`VirtualThreadTaskExecutor`. This `TaskExecutor` can be used in Spring Batch wherever a `TaskExecutor` is required. |
| 36 | +[[data-class-support]] |
| 37 | +== Data class support in JDBC item readers |
54 | 38 |
|
55 | | -[[memory-management-improvement-jpaitemwriter]] |
56 | | -== Memory management improvement in the JpaItemWriter |
| 39 | +This release introduces a new method in the builders of JDBC cursor and paging item readers that allows users to specify a |
| 40 | +`DataClassRowMapper` when the type of items is a data class (Java record or Kotlin data class). |
57 | 41 |
|
58 | | -When using the `JpaItemWriter`, the JPA persistence context can quickly grow when the chunk size |
59 | | -is large enough. This might lead to `OutOfMemoryError` errors if not cleared appropriately in a timely manner. |
| 42 | +The new method named `dataRowMapper(TargetType.class)` is similar to the `beanRowMapper(TargetType.class)` and is designed |
| 43 | +to make the configuration of row mappers consistent between regular classes (Java beans) and data classes (Java records). |
60 | 44 |
|
61 | | -In this release, a new option named `clearPersistenceContext` has been introduced in the `JpaItemWriter` |
62 | | -to clear the persistence context after writing each chunk of items. This option improves the memory management |
63 | | -of chunk-oriented steps dealing with large amounts of data and big chunk sizes. |
| 45 | +[[configurable-line-separator-in-recursivecollectionlineaggregator]] |
| 46 | +== Configurable line separator in RecursiveCollectionLineAggregator |
64 | 47 |
|
65 | | -[[new-synchronized-decorators]] |
66 | | -== New synchronized decorators for item readers and writers |
| 48 | +Up until now, the line separator property in `RecursiveCollectionLineAggregator` was set to the System's line separator value. |
| 49 | +While it is possible to change the value through a System property, this configuration style is not consistent with other properties |
| 50 | +of batch artifacts. |
67 | 51 |
|
68 | | -Up to version 5.0, Spring Batch provided two decorators `SynchronizedItemStreamReader` and `SynchronizedItemStreamWriter` |
69 | | -to synchronize thread access to `ItemStreamReader#read` and `ItemStreamWriter#write`. Those decorators are useful when |
70 | | -using non thread-safe item streams in multi-threaded steps. |
| 52 | +This release introduces a new setter in `RecursiveCollectionLineAggregator` that allows users to configure a custom value of |
| 53 | +the line separator without having to use System properties. |
71 | 54 |
|
72 | | -While those decorators work with `ItemStream` implementations, they are not usable with non-item streams. For example, |
73 | | -those decorators cannot be used to synchronize access to `ListItemReader#read` or `KafkaItemWriter#write`. |
| 55 | +[[job-registration-improvements]] |
| 56 | +== Job registration improvements |
74 | 57 |
|
75 | | -For users convenience, this release introduces new decorators for non-item streams as well. With this new feature, all |
76 | | -item readers and writers in Spring Batch can now be synchronized without having to write custom decorators. |
| 58 | +In version 5.1, the default configuration of batch infrastructure beans was updated to automatically populate the job registry |
| 59 | +by defining a `JobRegistryBeanPostProcessor` bean in the application context. After a recent change in Spring Framework |
| 60 | +that changed the log level in `BeanPostProcessorChecker`, several warnings related to the `JobRegistryBeanPostProcessor` were |
| 61 | +logged in a typical Spring Batch application. These warnings are due to the `JobRegistryBeanPostProcessor` having a dependency |
| 62 | +to a `JobRegistry` bean, which is not recommended and might cause bean lifecycle issues. |
77 | 63 |
|
78 | | -[[new-cursor-based-mongo-item-reader]] |
79 | | -=== New Cursor-based MongoItemReader |
80 | | - |
81 | | -Up to version 5.0, the `MongoItemReader` provided by Spring Batch used pagination, which is based on MongoDB's `skip` operation. |
82 | | -While this works well for small/medium data sets, it starts to perform poorly with large data sets. |
83 | | - |
84 | | -This release introduces the `MongoCursorItemReader`, a new cursor-based item reader for MongoDB. This implementation |
85 | | -uses cursors instead paging to read data from MongoDB, which improves the performance of reads on large collections. |
86 | | -For consistency with other cursor/paging readers, the current `MongoItemReader` has been renamed to `MongoPagingItemReader`. |
87 | | - |
88 | | -[[bulk-inserts-support-mongo-item-writer]] |
89 | | -=== Bulk inserts support in MongoItemWriter |
90 | | - |
91 | | -Up to version 5.0, the `MongoItemWriter` supported two operations: `upsert` and `delete`. While the `upsert` |
92 | | -operation works well for both inserts and updates, it does not perform well for items that are known to be new |
93 | | -in the target collection. |
94 | | - |
95 | | -Similar to the `persist` and `merge` operations in the `JpaItemWriter`, this release adds a new operation named |
96 | | -`insert` in the `MongoItemWriter`, which is designed for bulk inserts. This new option performs better than |
97 | | -`upsert` for new items as it does not require an additional lookup to check if items already exist in the target collection. |
98 | | - |
99 | | -[[new-item-reader-and-writer-for-redis]] |
100 | | -=== New item reader and writer for Redis |
101 | | - |
102 | | -A new `RedisItemReader` is now available in the library of built-in item readers. This reader is based on Spring Data Redis |
103 | | -and can be configured with a `ScanOptions` to scan the key set to read from Redis. |
104 | | - |
105 | | -Similarly, a new `RedisItemWriter` based on Spring Data Redis is now part of the writers library. This writer can be configured |
106 | | -with a `RedisTemplate` to write items to Redis. |
107 | | - |
108 | | -[[automatic-configuration-of-jobregistrybeanpostprocessor]] |
109 | | -=== Automatic configuration of JobRegistryBeanPostProcessor |
110 | | - |
111 | | -When configuring a `JobOperator` in a Spring Batch application, it is necessary to register the jobs in the operator's `JobRegistry`. |
112 | | -This registration process is either done manually or automatically by adding a `JobRegistryBeanPostProcessor` bean to the application |
113 | | -context. |
114 | | - |
115 | | -In this release, the default configuration of Spring Batch (ie by using `@EnableBatchProcessing` or extending `DefaultBatchConfiguration`) |
116 | | -now automatically registers a `JobRegistryBeanPostProcessor` bean to the application context. This simplifies the configuration process |
117 | | -and improves the user experience when using a `JobOperator`. |
118 | | - |
119 | | -[[ability-to-start-a-job-flow-with-a-decision]] |
120 | | -=== Ability to start a job flow with a decision |
121 | | - |
122 | | -When using the XML configuration style, it is possible to start a job flow with a decider thanks to the `<decision>` element. |
123 | | -However, up to version 5.0, it was not possible to achieve the same flow definition with the Java API. |
124 | | - |
125 | | -In this release, a new option to start a job flow with a `JobExecutionDecider` was added to the `JobBuilder` API. |
126 | | -This makes both configuration styles more consistent. |
127 | | - |
128 | | -[[ability-to-provide-a-custom-jobkeygenerator]] |
129 | | -=== Ability to provide a custom JobKeyGenerator |
130 | | - |
131 | | -By default, Spring Batch identifies job instances by calculating an MD5 hash of the identifying job parameters. While it is unlikely to |
132 | | -need to customize this identification process, Spring Batch still provide a strategy interface for users to override the default mechanism |
133 | | -through the `JobKeyGenerator` API. |
134 | | - |
135 | | -Up to version 5.0, it was not possible to provide a custom key generator without having to create a custom `JobRepository` and `JobExplorer`. |
136 | | -In this version, it is now possible to provide a custom `JobKeyGenerator` through the factory beans of `JobRepository` and `JobExplorer`. |
137 | | - |
138 | | -[[new-documentation-based-on-antora]] |
139 | | -=== New documentation based on Antora |
140 | | - |
141 | | -The reference documentation was updated to use https://antora.org[Antora]. This update introduces a number of improvements, including but not limited to: |
142 | | - |
143 | | -* Multi-version documentation: it is now possible to navigate from one version to another thanks to the drop down version list in the left side menu. |
144 | | -* Integrated search experience: powered by https://docsearch.algolia.com/[Algolia], the search experience in now better thanks to the integrated search box at the top left of the page |
145 | | -* Improved configuration style toggle: the toggle to switch between the XML and Java configuration styles for code snippets is now located near each sample, rather than the top of each page |
146 | | - |
147 | | -[[improved-getting-started-experience]] |
148 | | -=== Improved Getting Started experience |
149 | | - |
150 | | -In this release, the getting started experience was improved in many ways: |
151 | | - |
152 | | -* Samples are now packaged by feature and are provided in two configuration styles: XML and Java configuration |
153 | | -* A new https://github.com/spring-projects/spring-batch#two-minutes-tutorial[Two minutes tutorial] was added to the README |
154 | | -* The https://spring.io/guides/gs/batch-processing[Getting Started Guide] was updated to the latest and greatest Spring Batch and Spring Boot versions |
155 | | -* The https://github.com/spring-projects/spring-batch/blob/main/ISSUE_REPORTING.md[Issue Reporting Guide] was updated with detailed instructions and project templates to help you easily report issues |
156 | | - |
157 | | -[[mongodb-job-repository]] |
158 | | -=== MongoDB Job Repository (Experimental) |
159 | | - |
160 | | -This feature introduces new implementations of `JobRepository` and `JobExplorer` backed by MongoDB. This long-awaited feature is now available |
161 | | -as experimental and marks the introduction of the first NoSQL meta-data store for Spring Batch. |
162 | | - |
163 | | -Please refer to the https://github.com/spring-projects-experimental/spring-batch-experimental#mongodb-job-repository[Spring Batch Experimental] repository for more details about this feature. |
164 | | - |
165 | | -[[composite-item-reader]] |
166 | | -=== Composite Item Reader (Experimental) |
167 | | - |
168 | | -This feature introduces a composite `ItemReader` implementation. Similar to the `CompositeItemProcessor` and `CompositeItemWriter`, the idea is to delegate reading to a list of item readers in order. |
169 | | -This is useful when there is a requirement to read data having the same format from different sources (files, databases, etc). |
170 | | - |
171 | | -Please refer to the https://github.com/spring-projects-experimental/spring-batch-experimental#composite-item-reader[Spring Batch Experimental] repository for more details about this feature. |
172 | | - |
173 | | -[[new-chunk-oriented-step-implementation]] |
174 | | -=== New Chunk-Oriented Step implementation (Experimental) |
175 | | - |
176 | | -This is not a new feature, but rather a new implementation of the chunk-oriented processing model. |
177 | | -The goal is to address the reported issues with the current implementation and to provide a new base for the upcoming re-designed concurrency model. |
178 | | - |
179 | | -Please refer to the https://github.com/spring-projects-experimental/spring-batch-experimental#new-chunk-oriented-step-implementation[Spring Batch Experimental] repository for more details about this new implementation. |
| 64 | +These issues have been resolved in this release by changing the mechanism of populating the `JobRegistry` from using a `BeanPostProcessor` |
| 65 | +to using a `SmartInitializingSingleton`. The `JobRegistryBeanPostProcessor` is now deprecated in favor of the newly added `JobRegistrySmartInitializingSingleton`. |
0 commit comments