Spring批处理中的多个项目编写者 [英] Multiple itemwriters in Spring batch

查看:174
本文介绍了Spring批处理中的多个项目编写者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Spring批处理,我正在读取一大块数据,处理它然后我希望将这些数据传递给2个编写器。一个编写器只是更新数据库,而第二个编写器将写入csv文件。

I am currently writing a Spring batch where I am reading a chunk of data, processing it and then I wish to pass this data to 2 writers. One writer would simply update the database whereas the second writer will write to a csv file.

我打算编写自己的自定义编写器并在customItemWriter中注入两个itemWriters,并在customItemWriter的write方法中调用两个项目编写器的write方法。这种方法是否正确?是否有任何符合我要求的ItemWriter实现?

I am planning to write my own custom writer and inject the two itemWriters in the customItemWriter and call the write methods of both the item writers in the write method of customItemWriter. Is this approach correct? Are there any ItemWriter implementations available which meet my requirements?

提前致谢

推荐答案

您可以使用Spring的 CompositeItemWriter 和委托给你所有的作家。

这里是配置示例

You can use Spring's CompositeItemWriter and delegate to it all your writers.
here is a configuration example.

这篇关于Spring批处理中的多个项目编写者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆