Sidebar

How can we handle reading files from an unreliable network resource?

0 votes
404 views
asked Sep 17, 2013 by michael-h-5027 (14,390 points)
The server we are sending to is sometimes down. Don't want to get a channel shutdown or a ton of error messages.

1 Answer

0 votes
 
Best answer

You can setup your source node to read from a script that will look in the folder every five minutes or so and retry. 

 

try {
   // read all files in C:\HL7\*.hl7
   var incoming = new java.io.File("C:\\HL7\\");
   var allFiles = incoming.listFiles();
   if (allFiles !== null) {
      // skip folders and hidden files
      for (var i = 0; i < allFiles.length; i++) {
         var file = allFiles[i];
         if (!file.isDirectory() && !file.isHidden() && file.getName().endsWith('.hl7') && file.length() > 0) {
            // this call adds a new inbound message
            qie.addInboundMessage(qie.readFile(file), file.getName());
            // delete the file, now that we have processed it
            qie.deleteFile(file);
         }
      }
   }
} catch (err) {
   qie.debug('Cannot read file: ' + err);
}
answered Sep 17, 2013 by michael-h-5027 (14,390 points)
selected Dec 17, 2013 by ron-s-6919
...