Commit Graph

2061 Commits

Author SHA1 Message Date
Mahmoud Ben Hassine
1ff04d532d Deprecate throttle limit in TaskExecutorRepeatTemplate
Resolves #2218
2022-10-12 18:57:18 +02:00
Mahmoud Ben Hassine
f185fd1598 Deprecate JobRegistryBackgroundJobRunner 2022-10-12 18:49:31 +02:00
Mahmoud Ben Hassine
26c39cbbae Refine contribution #3967
Related to #752
2022-10-12 17:23:58 +02:00
Philippe Truche
746c919372 Support command as array of strings
setCommand now supports passing in an array of strings. When a single
string is supplied, it is tokenized by the Runtime#exec method. When an
array of strings is supplied, the array is supplied as is to the
Runtime#exec method in which case no tokenization takes place.

Resolves #752
2022-10-12 16:36:30 +02:00
Mahmoud Ben Hassine
4eefb1d287 Refine contribution #3972
Related to #3955
2022-10-12 15:37:45 +02:00
Stefano Cordio
eccea800fb Add CommandRunner and JvmCommandRunner in SystemCommandTasklet
This improves the testability of `SystemCommandTasklet` when the
target command is not available during test execution.

Resolves #3955
2022-10-12 14:56:07 +02:00
Mahmoud Ben Hassine
6fbbeb8e5b Fix timestamp precision in schema-derby.sql
Related to 81728c00ed
2022-10-12 08:38:27 +02:00
Mahmoud Ben Hassine
d66372a0fb Fix timestamp precision in schema-hsqldb-extended.sql
Related to 81728c00ed
2022-10-12 08:06:13 +02:00
Mahmoud Ben Hassine
81728c00ed Increase the value of fractional seconds precision in timestamp columns
This commit increases the value of fractional seconds precision to 9
for database providers that support a value higher than 6 (which is the
default value for most database providers).

The reason for this change is that a `java.time.LocalDateTime` has a
FSP of 9, and a round trip to the database as a `java.sql.Timestamp`
results in data loss at the FSP level.

Here is an example in JdbcStepExecutionDaoTests#testSaveAndGetExecution:

```
assertStepExecutionsAreEqual:318
   expected: <2022-10-12T03:42:01.305896170>
   but was:  <2022-10-12T03:42:01.305896>
```

Some DB providers like MySQL [1], Postgresql [2], SAP HANA [3],
SQLServer [4] and SyBase [5] do not support FSP up to 9.

[1]: https://dev.mysql.com/doc/refman/8.0/en/datetime.html
[2]: https://www.postgresql.org/docs/current/datatype-datetime.html
[3]: https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/3f81ccc7e35d44cbbc595c7d552c202a.html?version=2.0.02&locale=en-US
[4]: https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-ver16
[5]: https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/iqrefbb587.htm
2022-10-12 07:14:05 +02:00
Mahmoud Ben Hassine
5c92623785 Fix Timestamp to LocalDateTime conversion in Job/Step execution DAOs
Persisting a LocalDateTime as a Timestamp with `Timestamp.valueOf(LocalDateTime)`
and retrieving it with `ResultSet#getObject(index, LocalDateTime.class)` seems
to result in a data loss at the millisecond fraction level.

This commit changes the usage of `ResultSet#getObject(index, LocalDateTime.class)`
to `ResultSet#getTimestamp(index).toLocalDateTime()`.

A round trip to the database with `Timestamp.valueOf(LocalDateTime)` and
`Timestamp.toLocalDateTime()` should not result in a data loss.
2022-10-12 06:46:05 +02:00
Mahmoud Ben Hassine
1a65c00b8d Change type of timestamp fields in JobExecution/StepExecution to LocalDateTime
This commit changes the type of fields `startTime`, `endTime`,
`createTime` and `lastUpdated` in `JobExecution` and `StepExecution`
from `java.util.Date` to `java.time.LocalDateTime`.

Resolves #1014
2022-10-11 22:09:16 +02:00
Mahmoud Ben Hassine
2b258d1b88 Change the default execution context serializer to DefaultExecutionContextSerializer
This commit changes the default execution context serializer to
DefaultExecutionContextSerializer, which makes Jackson an optional
dependency.

Resolves #4140
2022-10-10 10:39:50 +02:00
Mahmoud Ben Hassine
c65e0f27d4 Change DefaultExecutionContextSerializer to produce Base64 content
Resolves #4122
Related to #3983
2022-10-10 10:20:13 +02:00
Mahmoud Ben Hassine
e21f56cad8 Remove version suffix from XSD schema
This is to be consistent with other XSDs from the portfolio
where the file of latest XSD is not suffixed with a version.
2022-10-09 18:01:34 +02:00
Mahmoud Ben Hassine
577638a1c1 Initialize jobParametersConverter in JobOperatorFactoryBean 2022-10-09 17:56:16 +02:00
Mahmoud Ben Hassine
6d73a1ceab ReApply "Adapt observability code to latest changes in Micrometer"
This reverts commit a774fac1b3.
2022-10-05 07:10:34 +02:00
Henning Poettker
a3c692d5fa Upgrade Derby to version 10.16.1.1 2022-10-04 23:20:59 +02:00
Mahmoud Ben Hassine
6ca1657d1b Add support for Java 8 Date/Time APIs as job parameters
The support to use any type as a job parameter was added
in #3960.

This commit introduces convenience methods where appropriate
to use Java 8 Date/Time APIs as job parameters.

Resolves #1035
2022-10-04 22:38:28 +02:00
Mahmoud Ben Hassine
fd9dca3504 Fix column names in BATCH_JOB_EXECUTION_PARAMS
For some DB providers, columns cannot be named "VALUE".
This commit adds a prefix where appropriate to the columns
of `BATCH_JOB_EXECUTION_PARAMS`.

Related to:

* https://github.com/spring-projects/spring-batch/issues/3960
2022-10-04 22:13:40 +02:00
Mahmoud Ben Hassine
2660f2bb27 Add support to use any type as a job parameter
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* https://github.com/spring-projects/spring-batch/issues/3960
* https://github.com/spring-projects/spring-batch/issues/2122
* https://github.com/spring-projects/spring-batch/issues/1035
* https://github.com/spring-projects/spring-batch/issues/1983
2022-10-04 20:35:50 +02:00
Mahmoud Ben Hassine
027302469a Fix native hints for JDK proxies generation 2022-10-04 11:07:33 +02:00
Mahmoud Ben Hassine
a774fac1b3 Revert "Adapt observability code to latest changes in Micrometer"
This reverts commit 8973c8a5b6.
2022-10-03 17:59:58 +02:00
Mahmoud Ben Hassine
bdd2cd4b25 Update core native hints
This commit adds a:

* JDK proxy hint for JobExplorer
* Reflection hint for fields of java.sql.Types
2022-10-01 12:08:40 +02:00
Glenn Renfro
8973c8a5b6 Adapt observability code to latest changes in Micrometer 2022-10-01 11:02:25 +02:00
Mahmoud Ben Hassine
219fee3bad Update documentation 2022-09-21 19:51:08 +02:00
Mahmoud Ben Hassine
1141975470 Add isolationLevelForCreate attribute in EnableBatchProcessing
Related to #3942
2022-09-21 19:08:55 +02:00
Mahmoud Ben Hassine
e33659cae5 Add support to customize transaction attributes in infrastructure beans
Before this commit, the transaction attributes were hardcoded and not
configurable in the proxy created by Job explorer/repository/operator
factory beans.

This commit adds the possibility to customize the transaction attributes
in addition to the transaction manager. It is now possible to configure
the transaction's isolation level as well as its propagation for each
method if needed.

Resolves #4195
2022-09-21 10:20:57 +02:00
Mahmoud Ben Hassine
6ad3596401 Add support for transaction customization in SimpleJobOperator
This commit adds support to configure and create a transactional
proxy around SimpleJobOperator through a factory bean.

The usage of `@Transactional` was removed in favor of
the programmatic way of customizing the proxy through
the factory bean.

Resolves #1078
2022-09-21 04:34:34 +02:00
Mahmoud Ben Hassine
40b4be3c14 Add transaction support in JobExplorerFactoryBean
This commit adds support to create a transactional
proxy around the JobExplorer created by the
JobExplorerFactoryBean.

Resolves #1307
2022-09-21 03:28:59 +02:00
Mahmoud Ben Hassine
aaf22e1860 Remove bean reference checks in BatchRegistrar
These checks occur too early in the bean creation/registration
process and might cause issues when initializing the context.

Related to #3942
2022-09-20 15:35:31 +02:00
Mahmoud Ben Hassine
48e437ae17 Revisit the configuration code of EnableBatchProcessing
Before this commit, the configuration of infrastructure beans
was confusing and not straightforward to customize. This commit
changes the way Batch infrastructure beans are configured.
The most important changes are:

* EnableBatchProcessing now provides new attributes to
configure properties of infrastructure beans
* Bean registration is now done programmatically with a
BeanDefinitionRegistrar instead of importing a class with
statically annotated bean definition methods
* Bean are now resolved from the application context directly
instead of being resolved from a BatchConfigurer
* Both a data source and a transaction manager are now
required to be defined in the application context
* A new configuration class called DefaultBatchConfiguration
with default infrastructure bean definitions is now provided
and can be extended to customize the default configuration

Resolves #3942
2022-09-20 12:24:10 +02:00
Mahmoud Ben Hassine
f39f07075a Improve Step/Job builder APIs to guide users to set mandatory properties
Before this commit, the user had to manually set the job repository and transaction
manager on `JobBuilder` and `StepBuilder` instances with a chained call to
`.repository(jobRepository)` and `.transactionManager(transactionManager)`.
This is error prone and can lead to runtime errors if these properties are not set.

This commit introduces new APIs to guide the user to set these properties at
builder creation time.

Resolves #4192
2022-09-17 22:31:12 +02:00
Mahmoud Ben Hassine
d11b5b2c3a Remove BatchConfigurer#getTransactionManager
Before this commit, the transaction manager was configurable
by implementing `BatchConfigurer#getTransactionManager`.

The transaction manager being an implementation detail of the
`JobRepository`, it should not be configurable at the same level
as the `JobRepository` (ie in the same interface).

This commit removes the method `getTransactionManager` from
the `BatchConfigurer` interface. If needed, a custom transaction
manager could be supplied by implementing `getJobRepository`,
or via the constructor of `DefaultBatchConfigurer`.

Resolves https://github.com/spring-projects/spring-batch/issues/4191
2022-09-13 20:02:32 +02:00
Mahmoud Ben Hassine
6e443cb1b1 Deprecate Job/Step builder factories
This commit deprecates JobBuilderFactory and StepBuilderFactory
in favor of the respective builders they create.

It also removes the exposure of such utilities as beans in the
application context when using `@EnableBatchProcessing`.

Resolves https://github.com/spring-projects/spring-batch/issues/4188
2022-09-13 16:56:01 +02:00
Mahmoud Ben Hassine
06c2dc3a01 Refine contribution #4187
Add resource hints for all supported databases
2022-09-12 07:41:14 +02:00
Glenn Renfro
2f8668d1f8 Add native hints for Spring Batch
Issue #4187
2022-09-12 07:36:14 +02:00
Tommy Ludwig
f20942e368 Adapt to ObservationConvention location change
See https://github.com/micrometer-metrics/micrometer/pull/3387
2022-09-09 15:41:45 +02:00
Mahmoud Ben Hassine
7c8fb172a7 Move the transaction manager configuration to AbstractTaskletStepBuilder
Before this commit, the transaction manager was configurable
at the StepBuilder level, which is inconsistent with the XML
config style in addition to be not needed for most step types.

This commit moves the configuration of the transaction manager
from the StepBuilder down to the AbstractTaskletStepBuilder,
which is the level where the transaction manager is needed.

Resolves #4130
2022-09-08 11:35:14 +02:00
Mahmoud Ben Hassine
bd25df6770 Put back "Fix StepScopeProxyTargetClassOverrideIntegrationTests"
Related to bbf7086765.
2022-08-24 20:07:21 +02:00
Mahmoud Ben Hassine
bbf7086765 Revert "Fix StepScopeProxyTargetClassOverrideIntegrationTests"
This reverts commit bf2e6ab0e5
as the change was made after spring-framework 6.0.0-M5 was
released. This version is required to release spring-batch
5.0.0-M5

This change will be put back after releasing 5.0.0-M5.
2022-08-24 18:11:18 +02:00
Henning Poettker
6bbd9d8379 Fix non-nullable columns in MySQL migration for Spring Batch 4.3
Issue #4145
2022-08-24 15:57:46 +02:00
Mahmoud Ben Hassine
c425137eec Remove datasource dependency in JobRepositoryTestUtils
Before this commit, the `JobRepositoryTestUtils` was
tied to the JDBC implementation of the `JobRepository`
as it was requiring a datasource. This makes it unusable
with implementations that do not rely on a datasource
to store batch meta-data (A MongoDB job repository for
instance where no datasource is used).

This commit decouples the `JobRepositoryTestUtils` from
the implementation details of the `JobRepository` by making
it working against the `JobRepository` interface.

This commit also introduces the necessary methods in the
`JobRepository` interface as well as various DAOs to
implement the utilities without having to deal with the
details of the underlying repository implementation.

Resolves #4070
2022-08-23 21:33:06 +02:00
Mahmoud Ben Hassine
fe40370f39 Refine contribution #4167
The documentation generation change introduced
in #4167 seems to scan more files than previously
WRT checking the code formatting style.

This commit fixes the formatting of the files
that do not conform to the Spring style.
2022-08-21 09:52:35 +02:00
Mahmoud Ben Hassine
e67c0069f1 Use the Chunk API consistently
This commit replaces the usage of List with Chunk
where appropriate. Summary of changes:

- The Chunk class was moved from the `org.springframework.batch.core.step.item` package to the `org.springframework.batch.item` package
- The signature of the method `ItemWriter#write(List)` was changed to `ItemWriter#write(Chunk)`
- All implementations of `ItemWriter` were updated to use the Chunk API instead of List
- All methods in the `ItemWriteListener` interface were updated to use the Chunk API instead of List
- All implementations of `ItemWriteListener` were updated to use the Chunk API instead of List
- The constructor of `ChunkRequest` was changed to accept a Chunk instead of a Collection of items
- The return type of `ChunkRequest#getItems()` was changed from List to Chunk

Resolves #3954
2022-08-19 13:40:09 +02:00
Mahmoud Ben Hassine
bf2e6ab0e5 Fix StepScopeProxyTargetClassOverrideIntegrationTests
This test started failing after an upstream change in Spring Framework,
see https://github.com/spring-projects/spring-framework/issues/28115
2022-08-16 11:49:30 +02:00
Mahmoud Ben Hassine
9211c2d211 Make MessageChannelPartitionHandler extend AbstractPartitionHandler 2022-08-03 10:52:36 +02:00
Henning Poettker
2fdb68d28e Migrate Spring Batch Core to JUnit Jupiter 2022-08-02 21:25:54 +02:00
Mahmoud Ben Hassine
4cb15ca837 Fix breaking changes in micrometer APIs
Related to https://github.com/micrometer-metrics/micrometer/pull/3310
2022-07-27 15:31:18 +02:00
Mahmoud Ben Hassine
96c6367dae Replace KeyValuesProvider with ObservationConvention
Related to https://github.com/micrometer-metrics/micrometer/pull/3306
2022-07-26 06:55:39 +02:00
Glenn Renfro
ee7d12671b Updated Batch Metrics to use DefaultMeterObservationHandler
instead of TimerObservationHandler
2022-07-21 11:32:35 +02:00