|
6 | 6 |
|
7 | 7 | == What's New in Spring Batch 4.3
|
8 | 8 |
|
9 |
| -TDB |
| 9 | +This release comes with a number of new features, performance improvements, |
| 10 | +dependency updates and API deprecations. This section describes the most |
| 11 | +important changes. For a complete list of changes, please refer to the |
| 12 | +https://github.com/spring-projects/spring-batch/releases/tag/4.3.0[release notes]. |
| 13 | + |
| 14 | +[[newFeatures]] |
| 15 | +=== New features |
| 16 | + |
| 17 | +==== New synchronized ItemStreamWriter |
| 18 | + |
| 19 | +Similar to the `SynchronizedItemStreamReader`, this release introduces a |
| 20 | +`SynchronizedItemStreamWriter`. This feature is useful in multi-threaded steps |
| 21 | +where concurrent threads need to be synchronized to not override each other's writes. |
| 22 | + |
| 23 | +==== New JpaQueryProvider for named queries |
| 24 | + |
| 25 | +This release introduces a new `JpaNamedQueryProvider` next to the |
| 26 | +`JpaNativeQueryProvider` to ease the configuration of JPA named queries when |
| 27 | +using the `JpaPagingItemReader`: |
| 28 | + |
| 29 | +[source, java] |
| 30 | +---- |
| 31 | +JpaPagingItemReader<Foo> reader = new JpaPagingItemReaderBuilder<Foo>() |
| 32 | + .name("fooReader") |
| 33 | + .queryProvider(new JpaNamedQueryProvider("allFoos", Foo.class)) |
| 34 | + // set other properties on the reader |
| 35 | + .build(); |
| 36 | +---- |
| 37 | + |
| 38 | +==== New JpaCursorItemReader Implementation |
| 39 | + |
| 40 | +JPA 2.2 added the ability to stream results as a cursor instead of only paging. |
| 41 | +This release introduces a new JPA item reader that uses this feature to |
| 42 | +stream results in a cursor-based fashion similar to the `JdbcCursorItemReader` |
| 43 | +and `HibernateCursorItemReader`. |
| 44 | + |
| 45 | +==== New JobParametersIncrementer implementation |
| 46 | + |
| 47 | +Similar to the `RunIdIncrementer`, this release adds a new `JobParametersIncrementer` |
| 48 | +that is based on a `DataFieldMaxValueIncrementer` from Spring Framework. |
| 49 | + |
| 50 | +==== GraalVM Support |
| 51 | + |
| 52 | +This release adds initial support to run Spring Batch applications on GraalVM. |
| 53 | +The support is still experimental and will be improved in future releases. |
| 54 | + |
| 55 | +==== Java records Support |
| 56 | + |
| 57 | +This release adds support to use Java records as items in chunk-oriented steps. |
| 58 | +The newly added `RecordFieldSetMapper` supports data mapping from flat files to |
| 59 | +Java records, as shown in the following example: |
| 60 | + |
| 61 | +[source, java] |
| 62 | +---- |
| 63 | +@Bean |
| 64 | +public FlatFileItemReader<Person> itemReader() { |
| 65 | + return new FlatFileItemReaderBuilder<Person>() |
| 66 | + .name("personReader") |
| 67 | + .resource(new FileSystemResource("persons.csv")) |
| 68 | + .delimited() |
| 69 | + .names("id", "name") |
| 70 | + .fieldSetMapper(new RecordFieldSetMapper<>(Person.class)) |
| 71 | + .build(); |
| 72 | +} |
| 73 | +---- |
| 74 | + |
| 75 | +In this example, the `Person` type is a Java record defined as follows: |
| 76 | + |
| 77 | +[source, java] |
| 78 | +---- |
| 79 | +public record Person(int id, String name) { } |
| 80 | +---- |
| 81 | + |
| 82 | +The `FlatFileItemReader` uses the new `RecordFieldSetMapper` to map data from |
| 83 | +the `persons.csv` file to records of type `Person`. |
| 84 | + |
| 85 | +[[performanceImprovements]] |
| 86 | +=== Performance improvements |
| 87 | + |
| 88 | +==== Use bulk writes in RepositoryItemWriter |
| 89 | + |
| 90 | +Up to version 4.2, in order to use `CrudRepository#saveAll` in `RepositoryItemWriter`, |
| 91 | +it was required to extend the writer and override `write(List)`. |
| 92 | + |
| 93 | +In this release, the `RepositoryItemWriter` has been updated to use |
| 94 | +`CrudRepository#saveAll` by default. |
| 95 | + |
| 96 | +==== Use bulk writes in MongoItemWriter |
| 97 | + |
| 98 | +The `MongoItemWriter` used `MongoOperations#save()` in a for loop |
| 99 | +to save items to the database. In this release, this writer has been |
| 100 | +updated to use `org.springframework.data.mongodb.core.BulkOperations` instead. |
| 101 | + |
| 102 | +==== Job start/restart time improvement |
| 103 | + |
| 104 | +The implementation of `JobRepository#getStepExecutionCount()` used to load |
| 105 | +all job executions and step executions in-memory to do the count on the framework |
| 106 | +side. In this release, the implementation has been changed to do a single call to |
| 107 | +the database with a SQL count query in order to count step executions. |
| 108 | + |
| 109 | +[[dependencyUpdates]] |
| 110 | +=== Dependency updates |
| 111 | + |
| 112 | +This release updates dependent Spring projects to the following versions: |
| 113 | + |
| 114 | +* Spring Framework 5.3 |
| 115 | +* Spring Data 2020.0 |
| 116 | +* Spring Integration 5.4 |
| 117 | +* Spring AMQP 2.3 |
| 118 | +* Spring for Apache Kafka 2.6 |
| 119 | +* Micrometer 1.5 |
| 120 | + |
| 121 | +[[deprecation]] |
| 122 | +=== Deprecations |
| 123 | + |
| 124 | +[[apiDeprecation]] |
| 125 | +==== API deprecation |
| 126 | + |
| 127 | +The following is a list of APIs that have been deprecated in this release: |
| 128 | + |
| 129 | +* `org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean` |
| 130 | +* `org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean` |
| 131 | +* `org.springframework.batch.core.repository.dao.MapJobInstanceDao` |
| 132 | +* `org.springframework.batch.core.repository.dao.MapJobExecutionDao` |
| 133 | +* `org.springframework.batch.core.repository.dao.MapStepExecutionDao` |
| 134 | +* `org.springframework.batch.core.repository.dao.MapExecutionContextDao` |
| 135 | +* `org.springframework.batch.item.data.AbstractNeo4jItemReader` |
| 136 | +* `org.springframework.batch.item.file.transform.Alignment` |
| 137 | +* `org.springframework.batch.item.xml.StaxUtils` |
| 138 | +* `org.springframework.batch.core.launch.support.ScheduledJobParametersFactory` |
| 139 | +* `org.springframework.batch.item.file.MultiResourceItemReader#getCurrentResource()` |
| 140 | +* `org.springframework.batch.core.JobExecution#stop()` |
| 141 | + |
| 142 | +Suggested replacements can be found in the Javadoc of each deprecated API. |
| 143 | + |
| 144 | +[[sqlfireDeprecation]] |
| 145 | +==== SQLFire support deprecation |
| 146 | + |
| 147 | +SQLFire has been in https://www.vmware.com/latam/products/pivotal-sqlfire.html[EOL] |
| 148 | +since November 1st, 2014. This release deprecates the support of using SQLFire |
| 149 | +as a job repository and schedules it for removal in version 5.0. |
0 commit comments