You can create a channel with a source of "Script" to get a count of the files in your folder.
var fileDirectory = new java.io.File("C:\\HL7\\In\\");
var listFiles = fileDirectory.listFiles();
var todaysFileCount = 0;
for (var i=0 ; i < listFiles.length ; i++) {
var file = listFiles[i];
if (!file.isDirectory() &&
!file.isHidden() &&
file.length() > 0) {
var todaysDate = qie.formatDate('ddMMyyyy');
var lastModDate = qie.formatDate('ddMMyyyy', new Date(file.lastModified()));
if (StringUtils.equals(todaysDate, lastModDate)) {
todaysFileCount++;
}
}
}
qie.addInboundMessage(todaysFileCount, 'fileCount');
If you wanted to get an error when the count is higher than a specified amount you could create a custom mapping that would throw an error if the count was too high.
var value = source.getNode("/");
if (value > 12) {
throw "The 'in' folder has " + value + " files pending!";
}