在遗留应用程序的调试/故障排除中,我需要一些指导。它是一个Java应用程序,旨在处理一个文件夹中的文件,并使用JMS(Java消息传递服务)将其放在主题上。此应用程序的问题在于,它会突然停止处理.txt文件而不会引发任何错误。例如,如果我将400个文件放在“导出”文件夹中,则应用程序开始对其进行处理,然后将其放入“导入”文件夹中(模仿在主题上放置消息的过程),但是在处理300个文件(有时为389个)后停止以此类推。负责处理这些文件的功能如下。您可以看到它具有多个catch()条件,以便在处理过程中遇到异常时进行捕获,但是到目前为止,我在日志中看不到任何东西可以帮助我确定问题的确切原因。
public void tmwRunFileWatcher() {
LOGGER.info("inputDirectory204##" + inputDirectory204);
boolean valid;
int eventCount = 0;
try {
do {
WatchKey watchKey = watchService.take();
eventCount = 0;
// List<WatchEvent<?>> eventList = watchKey.pollEvents();
// LOGGER.info("Number of events in list: {}", eventList.size());
for (WatchEvent event : watchKey.pollEvents()) {
eventCount++;
LOGGER.info("Event count: {}", eventCount);
if(StandardWatchEventKinds.OVERFLOW.equals(event.kind())) {
LOGGER.info("An overflow event has occurred. You will need to reprocess files");
}
if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind())) {
fileName = event.context().toString();
LOGGER.info("File Name before ignored: {}", fileName);
if (!(fileName.startsWith("TEMP_"))) {
Properties prop = jmsHeader(fileName);
String jmsMsg = processTmwMessage(inputDirectory204, fileName);
boolean msgFlag;
if (jmsMsg !=null && !(jmsMsg.equalsIgnoreCase("NOT READY"))) {
msgFlag = tmwPublisher.publishTmwMessageEvent(jmsMsg, prop);
if (msgFlag) {
move(inputDirectory204, fileName, dRDirectoryProducer);
}
LOGGER.info("File Processed successfully: {}",fileName);
}else{
LOGGER.info("File could not processed due to exception: {}",fileName);
}
}
}
}
valid = watchKey.reset();
LOGGER.info("WatchKey reset value: {}", valid);
} while (valid);
} catch (ClosedWatchServiceException closedWatchServiceException) {
LOGGER.error("Caught ClosedWatchServiceException: {}", closedWatchServiceException.getMessage());
} catch(InterruptedException interruptedException){
LOGGER.error("Caught InterruptedException: {}", interruptedException.getMessage());
} catch (MissingParentResourceException missingException) {
LOGGER.error("Caught InterruptedException: {}", missingException.getMessage());
} catch(Exception e){
LOGGER.error("Caught a Generic Exception: {}", e.getMessage());
}
}
有什么建议吗?