简体   繁体   English

完成任务后如何停止石英调度程序

[英]How to stop quartz scheduler after finishing a task

I am creating a Swing UI that will upload files from a directory. 我正在创建一个Swing UI,它将从目录上载文件。 We are scheduling this task using Quartz. 我们正在使用Quartz调度此任务。 Now my problem is, on press of Stop button, the scheduler should stop and the file upload process should also stop. 现在我的问题是,在按“停止”按钮时,调度程序应该停止并且文件上传过程也应该停止。 And I want a file either transfered fully or not at all. 而且我想要一个文件或者完全传输或者根本不传输。 How do I do that? 我怎么做?

code snippet of file upload 文件上传的代码段

File uploadDir = new File("E:\\SFTP_UPLOAD_DIR\\");
File[] listOfFiles = uploadDir.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
    if (listOfFiles[i].isFile()) {
       SftpUtil.uploadFile(ConfigurationClass.TEMP_FOLDER_LOCATION 
          + listOfFiles[i].getName(), host, userId, password, destDir);
    }
}

I am not sure of what you are actually want to achieve, but if you want to chain 2 jobs (one that uploads, and one that stop the scheduler), on can use the JobChainingJobListener ( http://quartz-scheduler.org/api/2.1.5/org/quartz/listeners/JobChainingJobListener.html ) 我不确定您实际要实现的目标,但是如果要链接2个工作(一个上载,一个停止调度程序),可以使用JobChainingJobListener( http://quartz-scheduler.org/ api / 2.1.5 / org / quartz / listeners / JobChainingJobListener.html

HIH HIH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM