You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-batch-docs/modules/ROOT/pages/retry.adoc
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,6 @@ Examples include remote calls to a web service that fails because of a network g
16
16
====
17
17
As of version 2.2.0, the retry functionality was pulled out of Spring Batch.
18
18
It is now part of a new library, https://github.com/spring-projects/spring-retry[Spring Retry].
19
-
Spring Batch still relies on Spring Retry to automate retry operations within the framework.
20
-
See the reference documentation of Spring Retry for details about
21
-
key APIs and how to use them.
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.
For example, you might increase the throttle-limit, as follows:
118
-
+
119
-
[source, xml]
120
-
----
121
-
<step id="loading"> <tasklet
122
-
task-executor="taskExecutor"
123
-
throttle-limit="20">...</tasklet>
124
-
</step>
125
-
----
126
-
127
-
====
128
-
129
-
130
-
89
+
might contain items that are non-consecutive compared to the single-threaded case.
131
90
132
91
Note also that there may be limits placed on concurrency by any pooled resources used in
133
92
your step, such as a `DataSource`. Be sure to make the pool in those resources at least
@@ -246,6 +205,63 @@ aggregating the exit statuses and transitioning.
246
205
247
206
See the section on xref:step/controlling-flow.adoc#split-flows[Split Flows] for more detail.
248
207
208
+
[[localChunking]]
209
+
== Local Chunking
210
+
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.
212
+
This is particularly useful when you have a large number of items to process and want to take advantage of multi-core processors.
213
+
With local chunking, you can configure a chunk-oriented step to use multiple threads to process chunks of items concurrently.
214
+
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.
215
+
216
+
This feature is possible by using the `ChunkMessageChannelItemWriter`, which is an item writer that submits chunk
217
+
requests to local workers from a `TaskExecutor`:
218
+
219
+
[source, java]
220
+
----
221
+
@Bean
222
+
public ChunkTaskExecutorItemWriter<Vet> itemWriter(ChunkProcessor<Vet> chunkProcessor) {
223
+
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
You can find an example of this scaling technique in the https://github.com/spring-projects/spring-batch/tree/main/spring-batch-samples/src/main/java/org/springframework/batch/samples/chunking/local[Local Chunking Sample].
264
+
249
265
[[remoteChunking]]
250
266
== Remote Chunking
251
267
@@ -543,3 +559,62 @@ The following example shows how to define late binding in XML:
543
559
544
560
====
545
561
562
+
[[remoteStep]]
563
+
== Remote Step execution
564
+
565
+
As of v6.0, Spring Batch provides support for remote step executions, allowing you to execute steps of a batch job on remote machines or clusters.
566
+
This feature is particularly useful for large-scale batch processing scenarios where you want to distribute the workload across multiple nodes to improve performance and scalability.
567
+
Remote step execution is provided by the `RemoteStep` class, which uses Spring Integration messaging channels to enable communication between the local job execution environment and the remote step executors.
568
+
569
+
A `RemoteStep` is configured as a regular step by providing the remote step name and a messaging template to send step execution requests to remote workers:
570
+
571
+
[source, java]
572
+
----
573
+
@Bean
574
+
public Step step(MessagingTemplate messagingTemplate, JobRepository jobRepository) {
575
+
return new RemoteStep("step", "workerStep", jobRepository, messagingTemplate);
576
+
}
577
+
----
578
+
579
+
On the worker side, you need to define the remote step to execute (`workerStep` in this example) and configure
580
+
a Spring Integration flow to intercept step execution requests and invoke the `StepExecutionRequestHandler`:
581
+
582
+
[source, java]
583
+
----
584
+
@Bean
585
+
public Step workerStep(JobRepository jobRepository, JdbcTransactionManager transactionManager) {
586
+
return new StepBuilder("workerStep", jobRepository)
587
+
// define step logic
588
+
.build();
589
+
}
590
+
591
+
/*
592
+
* Configure inbound flow (requests coming from the manager)
593
+
*/
594
+
@Bean
595
+
public DirectChannel requests() {
596
+
return new DirectChannel();
597
+
}
598
+
599
+
@Bean
600
+
public IntegrationFlow inboundFlow(ActiveMQConnectionFactory connectionFactory, JobRepository jobRepository,
601
+
StepLocator stepLocator) {
602
+
StepExecutionRequestHandler stepExecutionRequestHandler = new StepExecutionRequestHandler();
You can find a complete example in the https://github.com/spring-projects/spring-batch/tree/main/spring-batch-samples/src/main/java/org/springframework/batch/samples/remotestep[Remote Step Sample].
0 commit comments