[英]Spring batch GZIP ItemWriter/ItemReader
I have a Spring boot app, and I wrote some ItemWriter and ItemReaders, for example for JSON files and CSV files.我有一个 Spring Boot 应用程序,我编写了一些 ItemWriter 和 ItemReaders,例如用于 JSON 文件和 CSV 文件。
I want to add a step of compressing to GZIP and decompressing from GZIP.我想添加一个压缩到GZIP并从GZIP解压的步骤。
I wanted to know if it is possible to do as usual with JavaStreams -我想知道是否可以像往常一样使用 JavaStreams -
If I have some InputStream or OutputStream, I can decorate it with another stream (ie, another stream can get it in it's constructor and use it), and that way to get all of the streams' functionality easily.如果我有一些 InputStream 或 OutputStream,我可以用另一个流装饰它(即另一个流可以在它的构造函数中获取它并使用它),这样可以轻松获得所有流的功能。
Can it be done with the Spring ItemWriter and ItemReader?可以用 Spring ItemWriter 和 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.使用装饰器模式分别在
ItemWriter
和ItemReader
压缩或解压缩输出/输入ItemWriter
ItemReader
。 The restartability of the jobs that use those decorated ItemWriter
and ItemReader
, however, may be compromised.但是,使用那些装饰的
ItemWriter
和ItemReader
的作业的可重启性可能会受到影响。
...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.我建议一个单独的步骤-一个
TaskletStep
-用微进程来做到这压缩/解压缩。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.