Sidebar

How can i detect and empty file and discard using preprocess script.

0 votes
201 views
asked Apr 15, 2021 by brandon-w-8204 (33,270 points)
How can I discard messages with only whitespace (/r, /n, spaces)

1 Answer

0 votes

Use the following script on the source node in the preprocess script:

if (StringUtils.isBlank(new java.lang.String(bytesIn, 'UTF-8'))) {
   bytesOut = null;
} else {
   bytesOut = bytesIn;
}

if (bytesOut === null) {  //When null, the message is discarded and no further processing is done
   responseBytes = new java.lang.String('File does not contain any characters').getBytes(qie.getChannelEncoding());
}

answered Apr 15, 2021 by brandon-w-8204 (33,270 points)
...