2016-08-16 31 views
3

我有一个石英工作这样石英作业已完成,但该线程保持阻塞

@PersistJobDataAfterExecution 
@DisallowConcurrentExecution 
public class MyJob{ 

    public void execute(JobExecutionContext jec) throws JobExecutionException { 
     //connect to a FTP server, monitor directory for new files and download 
     //Using FTPClient of commons-net-3.5.jar 
    } 

作业被触发与

JobDetail jobDetail = newJob(MyJob.class) 
    .withIdentity(jobName, DEFAULT_GROUP) 
    .usingJobData(new JobDataMap(jobProperties)) 
    .build(); 

//trigger every minute     
Trigger trigger = newTrigger() 
    .withIdentity(jobName, DEFAULT_GROUP) 
    .startNow() 
    .withSchedule(cronSchedule(cronExpression)) 
    .build(); 

scheduler.scheduleJob(jobDetail,trigger); 

作业被触发的每一分钟。它运行良好大约1周(10000次执行)和莫名其妙地不能重新启动。日志中没有错误,并且看到它已经完成了以前的执行。其他进程正确启动。

升级库quartz-2.2.3commons-net-3.5(寻找在FTP库中的可能的错误)我设法过去的3周

我有一个Job监测Scheduler写着触发状态为BLOCKED。阻止进程的Thread不是由应用服务器

TriggerState triggerState = scheduler.getTriggerState(triggerKey); 

我还没有发现的文件上这种类型的用石英的问题,所以我怀疑是在FTP库由石英启动线程干扰的错误重复使用例如具有@PersistJobDataAfterExecution

使用我不知道这是一个众所周知的问题,或者可能是一个错误这样我就可以应用的解决方案或替代方法(杀死石英工作how to stop/interrupt quartz scheduler job manually

+0

它始终在相同的执行或时间内失败?工作分配了哪种模式? –

+0

失败时间在3天到3周(4300-30000次执行)之间变化,但偶尔在24h内失败。空执行后通常会失败:FTP连接,没有文件,断开连接。 cron表达式是:'0 0/1 * * *?' – pedrofb

+0

也许这个空执行会抛出任何未处理的异常或可能影响cron的错误?模式和工作似乎以正确的方式创建... –

回答

0

后偶有博士个月服务和OPS怀疑FTP连接错误阻止该服务,我们终于实现,这似乎解决问题

衡量每个流程执行现在要做的:

FTPClient ftp = new FTPClient(); 

//Added connection timeout before connect() 
ftp.setDefaultTimeout(getTimeoutInMilliseconds()); 

ftp.connect(host, port); 

//Added more timeouts to see if thread locks disappear... 
ftp.setBufferSize(1024 * 1024); 
ftp.setSoTimeout(getTimeoutInMilliseconds()); 

奇怪的是,这个过程是在connect()之前没有被阻止,过程继续并且没有重新启动而结束,但是当设置超时时,问题没有再次发生