简体   繁体   English

Spring 批处理 GZIP ItemWriter/ItemReader

[英]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.使用装饰器模式分别在ItemWriterItemReader压缩或解压缩输出/输入ItemWriter ItemReader The restartability of the jobs that use those decorated ItemWriter and ItemReader , however, may be compromised.但是,使用那些装饰的ItemWriterItemReader的作业的可重启性可能会受到影响。

...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.

相关问题 在Spring Batch中调用ItemReader,ItemProcessor,ItemWriter的构造函数时? - When constructors for ItemReader, ItemProcessor, ItemWriter are called in Spring Batch? 即使我没有itemReader和itemWriter用法,对我来说,spring-batch也是吗? - is spring-batch for me, even though I don't have a usage for itemReader and itemWriter? Spring Batch - ItemWriter 正在写入由 ItemReader 读取的相同对象,但不是通过 ItemProcessor 处理后返回的对象 - Spring Batch - ItemWriter is writing same object read by ItemReader but not the one returned after processing through ItemProcessor Spring Batch:如何从ItemReader或ItemWriter中访问当前步骤的ID /名称 - Spring Batch: How to access the current step's id / name from within an ItemReader or ItemWriter Spring 批处理 - 如何将多个项目的列表从输入传递到 ItemReader、ItemProcessor 和 ItemWriter - Spring Batch- how to pass list of multiple items from input to ItemReader, ItemProcessor and ItemWriter Spring批处理多线程ItemWriter - Spring batch multithreaded ItemWriter Spring 批量通配符ItemWriter - Spring Batch Wildcard ItemWriter Spring Batch:自定义ItemReader - Spring Batch : custom ItemReader spring batch:没有ItemWriter的Tasklet - spring batch : Tasklet without ItemWriter Spring Batch Json定制ItemWriter - Spring Batch Json custom ItemWriter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM