I have a requirement by which I have to sftp files to a destination:
I have written a simple Spring boot app which has a Component
like this with Services
that do different things:
@Component
public class FileExportSchedulerTask {
@Autowired
private FileService fileService;
@Autowired
private SFTPService sftpService;
public void run(String schedule) {
logger.info("Running Export Scheduler Task...{} " + schedule);
//gets list of files as Metadata objects which fileService deals with and send to sftpService to extract file path and initiate transfer
}
}
The FileService
returns the list of files concerned that need to be taken care of by the SftpService
and publish to destination. This is in the form of FileMetaData
object that has the file path as a field.
After I send each file, I need to write some file metadata information to the database. I have the following metadata object:
public class FileMetaData {
private String reportId;
private String reportName;
private String customer;
private String format;
private Date cobDate;
private String filePath;
}
For each metadata objects received by SFTPService
will extract the path and send to destination. The quantity of report is about 50-100 for each of my schedules.
I am having difficulty in thinking how to write to the Database the metadata object SftpService
received. Can you guys please give me suggestion what approach is best and how I can implement jdbc inserts for each transfer or if transferred objects should be queued and then one insert to the database.
I am not sure how to persist this information for each file transferred and then how to write to the database. Some recommendations and examples with code sample would assist very much :)
Aucun commentaire:
Enregistrer un commentaire