I have a Spring boot app, and I wrote some ItemWriter and ItemReaders, for example for JSON files and CSV files.
I want to add a step of compressing to GZIP and decompressing from GZIP.
I wanted to know if it is possible to do as usual with JavaStreams -
If I have some InputStream or OutputStream, I can decorate it with another stream (i.e., another stream can get it in it's constructor and use it), and that way to get all of the streams' functionality easily.
Can it be done with the Spring ItemWriter and ItemReader?
Else, what's the best way to add compressing and decompressing to an existing writers and readers?
Given that there are no other answers yet...let me propose a solution...
It won't be that hard to employ the Decorator Pattern to have the output/input compressed or decompressed in a ItemWriter
and ItemReader
, respectivly. The restartability of the jobs that use those decorated ItemWriter
and ItemReader
, however, may be compromised.
...what's the best way to add compressing and decompressing to an existing writers and readers?
I'd suggest a separate step - a TaskletStep
- with a Tasklet to do just the compression/decompression.