Skip to content

Commit 4da3695

Browse files
committed
Update reference documentation for v6.0
1 parent 4e5b7d2 commit 4da3695

23 files changed

+359
-762
lines changed

README.md

Lines changed: 31 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -28,88 +28,51 @@ In your favorite IDE, create a new Maven-based Java 17+ project and add the foll
2828
<artifactId>spring-batch-core</artifactId>
2929
<version>${LATEST_VERSION}</version>
3030
</dependency>
31-
<dependency>
32-
<groupId>org.hsqldb</groupId>
33-
<artifactId>hsqldb</artifactId>
34-
<version>${LATEST_VERSION}</version>
35-
<scope>runtime</scope>
36-
</dependency>
3731
</dependencies>
3832
```
3933

40-
Then, create a configuration class to define the datasource and transaction manager that will be used by the job repository:
41-
42-
```java
43-
import javax.sql.DataSource;
44-
45-
import org.springframework.context.annotation.Bean;
46-
import org.springframework.context.annotation.Configuration;
47-
import org.springframework.jdbc.support.JdbcTransactionManager;
48-
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
49-
50-
@Configuration
51-
public class DataSourceConfiguration {
52-
53-
@Bean
54-
public DataSource dataSource() {
55-
return new EmbeddedDatabaseBuilder()
56-
.addScript("/org/springframework/batch/core/schema-hsqldb.sql")
57-
.build();
58-
}
59-
60-
@Bean
61-
public JdbcTransactionManager transactionManager(DataSource dataSource) {
62-
return new JdbcTransactionManager(dataSource);
63-
}
64-
65-
}
66-
```
67-
68-
In this tutorial, an embedded [HSQLDB](http://www.hsqldb.org) database is created and initialized with Spring Batch's meta-data tables.
69-
70-
Finally, create a class to define the batch job:
34+
Then, create a class to define the batch job:
7135

7236
```java
73-
import org.springframework.batch.core.Job;
74-
import org.springframework.batch.core.JobParameters;
75-
import org.springframework.batch.core.Step;
37+
import org.springframework.batch.core.job.Job;
38+
import org.springframework.batch.core.job.parameters.JobParameters;
39+
import org.springframework.batch.core.launch.JobOperator;
40+
import org.springframework.batch.core.step.Step;
7641
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
7742
import org.springframework.batch.core.job.builder.JobBuilder;
78-
import org.springframework.batch.core.launch.JobLauncher;
7943
import org.springframework.batch.core.repository.JobRepository;
8044
import org.springframework.batch.core.step.builder.StepBuilder;
81-
import org.springframework.batch.repeat.RepeatStatus;
45+
import org.springframework.batch.infrastructure.repeat.RepeatStatus;
8246
import org.springframework.context.ApplicationContext;
8347
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
8448
import org.springframework.context.annotation.Bean;
8549
import org.springframework.context.annotation.Configuration;
86-
import org.springframework.context.annotation.Import;
87-
import org.springframework.jdbc.support.JdbcTransactionManager;
8850

8951
@Configuration
9052
@EnableBatchProcessing
91-
@Import(DataSourceConfiguration.class)
9253
public class HelloWorldJobConfiguration {
9354

94-
@Bean
95-
public Step step(JobRepository jobRepository, JdbcTransactionManager transactionManager) {
96-
return new StepBuilder("step", jobRepository).tasklet((contribution, chunkContext) -> {
97-
System.out.println("Hello world!");
98-
return RepeatStatus.FINISHED;
99-
}, transactionManager).build();
100-
}
101-
102-
@Bean
103-
public Job job(JobRepository jobRepository, Step step) {
104-
return new JobBuilder("job", jobRepository).start(step).build();
105-
}
106-
107-
public static void main(String[] args) throws Exception {
108-
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldJobConfiguration.class);
109-
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
110-
Job job = context.getBean(Job.class);
111-
jobLauncher.run(job, new JobParameters());
112-
}
55+
@Bean
56+
public Step step(JobRepository jobRepository) {
57+
return new StepBuilder(jobRepository).tasklet((contribution, chunkContext) -> {
58+
System.out.println("Hello world!");
59+
return RepeatStatus.FINISHED;
60+
}).build();
61+
}
62+
63+
@Bean
64+
public Job job(JobRepository jobRepository, Step step) {
65+
return new JobBuilder(jobRepository)
66+
.start(step)
67+
.build();
68+
}
69+
70+
public static void main(String[] args) throws Exception {
71+
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldJobConfiguration.class);
72+
JobOperator jobOperator = context.getBean(JobOperator.class);
73+
Job job = context.getBean(Job.class);
74+
jobOperator.start(job, new JobParameters());
75+
}
11376

11477
}
11578
```
@@ -119,16 +82,11 @@ The job in this tutorial is composed of a single step that prints "Hello world!"
11982
You can now run the `main` method of the `HelloWorldJobConfiguration` class to launch the job. The output should be similar to the following:
12083

12184
```
122-
INFO: Finished Spring Batch infrastructure beans configuration in 8 ms.
123-
INFO: Starting embedded database: url='jdbc:hsqldb:mem:testdb', username='sa'
124-
INFO: No database type set, using meta data indicating: HSQL
125-
INFO: No Micrometer observation registry found, defaulting to ObservationRegistry.NOOP
126-
INFO: No TaskExecutor has been set, defaulting to synchronous executor.
127-
INFO: Job: [SimpleJob: [name=job]] launched with the following parameters: [{}]
128-
INFO: Executing step: [step]
85+
[main] INFO org.springframework.batch.core.launch.support.TaskExecutorJobLauncher - COMMONS-LOGGING Job: [SimpleJob: [name=job]] launched with the following parameters: [{}]
86+
[main] INFO org.springframework.batch.core.job.SimpleStepHandler - COMMONS-LOGGING Executing step: [step]
12987
Hello world!
130-
INFO: Step: [step] executed in 10ms
131-
INFO: Job: [SimpleJob: [name=job]] completed with the following parameters: [{}] and the following status: [COMPLETED] in 25ms
88+
[main] INFO org.springframework.batch.core.step.AbstractStep - COMMONS-LOGGING Step: [step] executed in 3ms
89+
[main] INFO org.springframework.batch.core.launch.support.TaskExecutorJobLauncher - COMMONS-LOGGING Job: [SimpleJob: [name=job]] completed with the following parameters: [{}] and the following status: [COMPLETED] in 4ms
13290
```
13391

13492
## Getting Started Guide

spring-batch-docs/modules/ROOT/nav.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@
5151
** xref:spring-batch-integration/namespace-support.adoc[]
5252
** xref:spring-batch-integration/launching-jobs-through-messages.adoc[]
5353
** xref:spring-batch-integration/available-attributes-of-the-job-launching-gateway.adoc[]
54-
** xref:spring-batch-integration/sub-elements.adoc[]
54+
** xref:spring-batch-integration/providing-feedback-with-informational-messages.adoc[Providing Feedback with Informational Messages]
55+
** xref:spring-batch-integration/asynchronous-processing.adoc[Asynchronous Processors]
56+
** xref:spring-batch-integration/externelazing-execution.adoc[Externalizing Batch Process Execution]
5557
* xref:spring-batch-observability.adoc[]
5658
** xref:spring-batch-observability/micrometer.adoc[]
5759
** xref:spring-batch-observability/jfr.adoc[]
5860
* Appendices
5961
** xref:appendix.adoc[]
6062
** xref:schema-appendix.adoc[]
61-
** xref:transaction-appendix.adoc[]
6263
** xref:glossary.adoc[]
6364
** xref:faq.adoc[]

spring-batch-docs/modules/ROOT/pages/domain.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,5 @@ information on configuring a Job in xref:job.adoc[Configuring and Running a Job]
657657
. You can find more information on configuring a `Step` in
658658
xref:step.adoc[Configuring a Step].
659659

660+
WARNING: The batch XML namespace is deprecated as of Spring Batch 6.0 and will be removed in version 7.0.
661+

spring-batch-docs/modules/ROOT/pages/index.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ The reference documentation is divided into several sections:
77
[horizontal]
88
xref:spring-batch-intro.adoc[Spring Batch Introduction] :: Background, usage
99
scenarios, and general guidelines.
10+
xref:whatsnew.adoc[What's new in Spring Batch 6.0] :: New features introduced in version 6.0.
1011
xref:spring-batch-architecture.adoc[Spring Batch Architecture] :: Spring Batch
1112
architecture, general batch principles, batch processing strategies.
12-
xref:whatsnew.adoc[What's new in Spring Batch 6.0] :: New features introduced in version 6.0.
1313
xref:domain.adoc[The Domain Language of Batch] :: Core concepts and abstractions
1414
of the Batch domain language.
1515
xref:job.adoc[Configuring and Running a Job] :: Job configuration, execution, and
@@ -23,7 +23,7 @@ xref:scalability.adoc#scalability[Scaling and Parallel Processing] :: Multi-thre
2323
parallel steps, remote chunking, and partitioning.
2424
<<repeat.adoc#repeat,Repeat>> :: Completion policies and exception handling of repetitive actions.
2525
<<retry.adoc#retry,Retry>> :: Retry and backoff policies of retryable operations.
26-
xref:testing.adoc[Unit Testing] :: Job and Step testing facilities and APIs.
26+
xref:testing.adoc[Unit and Integration Testing] :: Job and Step testing facilities and APIs.
2727
xref:common-patterns.adoc#commonPatterns[Common Patterns] :: Common batch processing patterns
2828
and guidelines.
2929
xref:spring-batch-integration.adoc[Spring Batch Integration] :: Integration
@@ -38,8 +38,6 @@ xref:appendix.adoc#listOfReadersAndWriters[List of ItemReaders and ItemWriters]
3838
all provided item readers and writers.
3939
xref:schema-appendix.adoc#metaDataSchema[Meta-Data Schema] :: Core tables used by the Batch
4040
domain model.
41-
xref:transaction-appendix.adoc#transactions[Batch Processing and Transactions] :: Transaction
42-
boundaries, propagation, and isolation levels used in Spring Batch.
4341
<<glossary.adoc#glossary,Glossary>> :: Glossary of common terms, concepts, and vocabulary of
4442
the Batch domain.
4543
<<faq.adoc#faq,Frequently Asked Questions>> :: Frequently Asked Questions about Spring Batch.

spring-batch-docs/modules/ROOT/pages/job/configuring-infrastructure.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ created, in addition to a number of beans being made available to be autowired:
2020

2121
* `JobRepository`: a bean named `jobRepository`
2222
* `JobOperator`: a bean named `jobOperator`
23-
* `JobRegistry`: a bean named `jobRegistry`
2423

2524
Here is an example of how to use the `@EnableBatchProcessing` annotation in a Java configuration class:
2625

spring-batch-docs/modules/ROOT/pages/job/configuring-repository.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ of the various persisted domain objects within Spring Batch, such as `JobExecuti
66
It is required by many of the major framework features, such as the `JobOperator`,
77
`Job`, and `Step`.
88

9+
== Configuring a Resourceless JobRepository
10+
11+
The simplest implementation of the `JobRepository` interface is the
12+
`ResourcelessJobRepository`. This implementation does not use or store batch meta-data.
13+
It is intended for use-cases where restartability is not required and where the execution context
14+
is not involved in any way (like sharing data between steps through the execution context,
15+
or partitioned steps where partitions meta-data is shared between the manager and workers through
16+
the execution context, etc). This implementation holds the minimal state to run a single job
17+
(ie 1 job instance + 1 job execution + N step executions). This is suitable for one-time jobs
18+
executed in their own JVM. This job repository works with transactional steps as well as non-transactional
19+
steps (in conjunction with `ResourcelessTransactionManager`).
20+
21+
IMPORTANT: This implementation is *not* thread-safe and should *not* be used in any concurrent environment.
22+
23+
By default, when using `@EnableBatchProcessing` or `DefaultBatchConfiguration`, a `ResourcelessJobRepository`
24+
is provided for you.
25+
926
== Configuring a JDBC JobRepository
1027

1128
[tabs]

spring-batch-docs/modules/ROOT/pages/job/running.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ create an `ApplicationContext`. This file
5252
should contain everything needed to run the complete
5353
`Job`, including a `JobOperator`, a `JobRepository` and a `JobRegistry` populated with the jobs to operate.
5454
|`operation`|The name of the operation to execute on the job. Can be one of [`start`, `startNextInstance`, `stop`, `restart`, `abandon`]
55-
|`jobName` or `jobExecutionId`|Depending on the operation, this can be the name of the job to start or the execution ID of the job to stop, restart or abandon.
55+
|`jobName` or `jobExecutionId`|Depending on the operation, this can be the name of the job to start or the execution ID of the job to stop, restart, abandon or recover.
5656
|===============
5757

5858
When starting a job, all arguments after these are considered to be job parameters, are turned into a `JobParameters` object,
59-
and must be in the format of `name=value`. In the case of stopping, restarting or abandoning a job, the `jobExecutionId` is
59+
and must be in the format of `name=value,type,identifying`. In the case of stopping, restarting, abandoning or recovering a job, the `jobExecutionId` is
6060
expected as the 4th argument, and all remaining arguments are ignored.
6161

6262
The following example shows a date passed as a job parameter to a job defined in Java:

spring-batch-docs/modules/ROOT/pages/readers-and-writers/item-reader.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ input operations, as shown in the following interface definition:
2828
----
2929
public interface ItemReader<T> {
3030
31-
T read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException;
31+
T read() throws Exception;
3232
3333
}
3434
----

spring-batch-docs/modules/ROOT/pages/retry.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Examples include remote calls to a web service that fails because of a network g
1414

1515
[NOTE]
1616
====
17-
As of version 2.2.0, the retry functionality was pulled out of Spring Batch.
18-
It is now part of a new library, https://github.com/spring-projects/spring-retry[Spring Retry].
19-
As of v6.0, Spring Batch does *not* use Spring Retry to automate retry operations within the framework,
20-
and is now based on the https://docs.spring.io/spring-framework/reference/7.0/core/resilience.html#resilience-annotations-retryable[retry feature] provided by Spring Framework 7.0.
17+
As of v6.0, Spring Batch does *not* use https://github.com/spring-projects/spring-retry[Spring Retry] to automate retry operations within the framework,
18+
and is now based on the https://docs.spring.io/spring-framework/reference/7.0/core/resilience.html[core retry feature] provided by Spring Framework 7.0.
2119
====

spring-batch-docs/modules/ROOT/pages/scalability.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ See the section on xref:step/controlling-flow.adoc#split-flows[Split Flows] for
208208
[[localChunking]]
209209
== Local Chunking
210210

211-
Local chunking is a new feature that allows you to process chunks of items in parallel, locally within the same JVM using multiple threads.
211+
Local chunking is a new feature in v6.0 that allows you to process chunks of items in parallel, locally within the same JVM using multiple threads.
212212
This is particularly useful when you have a large number of items to process and want to take advantage of multi-core processors.
213213
With local chunking, you can configure a chunk-oriented step to use multiple threads to process chunks of items concurrently.
214214
Each thread will read, process and write its own chunk of items independently, while the step will manage the overall execution and commit the results.
@@ -292,7 +292,7 @@ message. JMS is the obvious candidate, but other options (such as JavaSpaces) ex
292292
the grid computing and shared memory product space.
293293

294294
See the section on
295-
xref:spring-batch-integration/sub-elements.adoc#remote-chunking[Spring Batch Integration - Remote Chunking]
295+
xref:spring-batch-integration/externelazing-execution.adoc#remote-chunking[Spring Batch Integration - Remote Chunking]
296296
for more detail.
297297

298298
[[partitioning]]

0 commit comments

Comments
 (0)