我有一个要求,对于wmq中传入的每15条肥皂消息,我需要制作包含这15条记录的文本文件并将其放在一个文件夹中。
除此之外,如果在30分钟内,如果我们无法收到15个肥皂,那么制作文本文件,无论我们有什么记录。
简而言之,要么制作一个包含15条记录的文本文件,要么在30分钟内制作一个标记符合标准的文本文件。
我应用同样的方法并且工作正常。但是从最近2天发生的事情来看,即使我的流量停止,也会在该文件夹中创建0 kb大小的文件。 这是我使用的计时器逻辑:
private TimeOutBC()
{
//Private constructor for singleton
}
public static TimeOutBC getInstance(){
return timeOut;
}
public void schedule(int seconds) {
timer=new Timer();
System.out.println(timer.hashCode());
currentTimeInMillis=System.currentTimeMillis();
timeMap.put(currentTimeInMillis, timer);
timer.schedule(new TimoutTask(), seconds * 1000);
}
public void cancelTimer(){
timer.cancel();
}
class TimoutTask extends TimerTask {
public void run() {
try {
catalogueTransform.checkTimer(CatalogueTransform.m);
CatalogueTransform.m=CatalogueTransform.m+1;
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error("errro whle setting time for file",e);
}
timer.cancel();
}
}
}
任何人都可以建议我,这个问题可能背后的原因是什么。