50,000 foot overview
I need to incorporate WebService reader support for SOAP and REST into an existing product built around Spring Batch.
Prior versions of the code used the reficio Soap libraries, which:
Their recommendations are to use the Spring webservices libraries.
The plan so far ...
The expectation was that we would build ItemReader
using RestTemplate and/or SOAP client components, and forget about it.
Oops ...
As we started designing the changes, we discovered that RestTemplate
has been deprecated since Spring 5.0 . The recommended replacement is WebClient
. While the RestTemplate
is still present, we don't want to build in technical debt by using a component that we know is going away. (Link: https://github.com/spring-guides/gs-consuming-rest/issues/28)
On March 25 2021, in https://github.com/spring-projects/spring-batch/issues/1008 , fmbenhassine states:
First of all, Reactive Streams are designed for data streams (infinite) while Spring Batch is a batch processing framework designed for fixed datasets (finite). In my opinion, this is already a fundamental mismtatch that can result in a non-natural integration between these two tools.
... snip ...
Moreover, the current chunk-oriented processing model is actually incompatible with the reactive paradigm. The reason is that ChunkOrientedTasklet waits for the chunkProcessor (processor + writer) to process the whole chunk before reading the next chunk:
Now back to the question:
With RestTemplate being deprecated, and WebClient being a reactive component, what is the best option for building Itemreaders of REST and SOAP webservices in spring batch?
RestTemplate
being in maintenance mode does not necessarily mean that it is deprecated or will go away. If that is the case, it will be clearly mentioned with a @Deprecated
annotation.
That said, you can use both clients with Spring Batch. The point I am trying to make in the issue you shared is that it does not make sense to use a reactive item reader if other parts of the stack are not reactive. So nothing prevents you from using a reactive item reader with the current implementation, you just won't have any benefits from using it over a non reactive component.