I am interfacing with a system which schedules appointments. The destination system does not allow appointments to be scheduled more than 30 days in advance, but the source system may send the appointment at any time (frequently beyond 30 days). How can I delay the delivery of the message till it is within the 30d window?
Create two channels. Have the first write the file to disk and set the "lastWriteTime" to the date you would like the message to be delivered. The second channel should read from this directory and use the "Check File Time" option to filter only those messages with historical dates.
channelMap.put('deliverAfter', msg['SCH']['SCH.11']['SCH.11.1'].toString());
Connector Type: Javascript Writer
var deliverAfter = DateUtil.getDate('yyyyMMddHHmm', $('deliverAfter'));
var path = 'c:/data/queue/' + connectorMessage.getMessageId();
org.apache.commons.io.FileUtils.writeStringToFile(new java.io.File(path), connectorMessage.getEncodedData(), 'UTF-8');
java.nio.file.Files.setLastModifiedTime(java.nio.file.Paths.get(path), java.nio.file.attribute.FileTime.fromMillis(deliverAfter.getTime()));
Path: c:/data/queue/
After Processing Action: Delete
Check File Age: Yes
File age (ms): 1000
Encoding: UTF-8