Spring Batch:如何使用Spring Batch从sftp服务器读取文件并将其保存到数据库中? [英] Spring Batch : How to use spring batch to read file from sftp server and save it into database?

查看:232
本文介绍了Spring Batch:如何使用Spring Batch从sftp服务器读取文件并将其保存到数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的项目基于Spring Batch和Spring集成.

My current project is based on Spring Batch and Spring integration.

我的目标是使用Spring Batch执行作业流程步骤:

My goal is using Spring Batch to execute job flow steps:

  1. 从SFTP服务器读取文件(步骤1).
  2. 解密文件(步骤2).
  3. 将文件保存到数据库中(步骤3).

我想将其分为步骤队列(从sftp读取,解密,写入db). 而且我还需要将文件,传输开始时间,传输结束时间,文件大小保存到数据库中.

I want to divide this into steps queue(read from sftp, decrypt, write to db). And I also need to save the file, transfer start time, transfer end time, file size into DB.

几天前,我使用Spring集成从sftp服务器轮询文件,然后将其发送到Spring批处理以完成额外的工作.我也无法获得转帐的开始时间.

Some days ago, I used Spring integration to poll file from sftp server and then send it to Spring batch to do the extra job. Also I can not get the transfer start time.

但是现在我的项目主要基于Spring批处理,而不是Spring Integration.

But now my project is main based on Spring batch, not Spring Integration.

能给我一些建议吗?

或者,您能告诉我如何使用Spring Batch来驱动Spring Integration读取SFTP文件.

Or, can you show me how to use Spring Batch to drive Spring Integration for reading SFTP files.

该如何获取转帐开始时间?

And how can I get the transfer start time ?

谢谢. :)

推荐答案

添加一个tasklet作为第一步;让Tasklet调用Spring Integration流,可能使用通过sftp出站网关GET文件.

Add a tasklet as the first step; have the tasklet invoke a Spring Integration flow, probably using an sftp outbound gateway to GET the file.

sftp中有一个如何使用网关的示例样本.

转移开始时间"就是您调用网关的时间.

The 'transfer start time' would be the time you invoke the gateway.

这篇关于Spring Batch:如何使用Spring Batch从sftp服务器读取文件并将其保存到数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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