1.4.4 drain

Note!

Drain is applicable for batch workflows only.

The drain function block is executed right before an endBatch block, and is treated as a final consume block. For instance, if a batch containing ten UDRs is processed by the agent, consume will be executed ten times before the drain function block is called. This is useful, for instance when collecting statistical data for a batch which is to be routed as a new UDR. The advantage with drain is that all consume features (except for the input built-in variable) are accessible, as opposed to the endBatch function block.

Example - How to use drain

int UDRCounter;
int file_count;
consume {
 UDRCounter=UDRCounter+1;
 udrRoute(input);
}
drain {
 myFolder.myUFDLFile.myTrailerFormat myTrailer;
 myTrailer=udrCreate(myFolder.myUFDLFile.myTrailerFormat);
 myTrailer.closingdate=dateCreateNow();
 myTrailer.numberOfUDRs=UDRCounter;
 myTrailer.sourceFileName=(string)mimGet("Disk_1",
 "Source Filename");
 udrRoute(myTrailer);
}
 
endBatch{
 file_count = file_count + 1;
 debug( "Number of UDRs in file:" + UDR_count );
}