Each file listener data instance references a single Service File rule. At run time, the
listener monitors the contents of a directory to look for files of a specific name (or name
pattern). When an eligible input file is discovered, it is copied into a subdirectory folder
and deleted from the original directory.
The listener cause the associated Service File rule to start. (If authentication is
required, the Operator ID and password in the listener are used, resulting in a full
requestor session. The Service File rule parses the input according to instructions in the
Request and Method tabs. When an input file is completely processed without error, it is
copied to the
folder and deleted from the
The system places output text files in a subdirectory of the original directory named
Report. Output files have a file type of
The system saves results and errors from Service File processing in persistent instances of the Log-Service-File class, ordered by date and time. This Log instance contains information about the file name, file size, and errors. You can use the Application Explorer to review these as XML displays in Internet Explorer, or you can create reports.
To include the clipboard results of service file processing in the Pega log, temporarily
add the Log-Message method as a step in an appropriate place in the service activity. Set
the LoggingLevel parameter to
and the Message parameter to:
Contents of page:\n" + myStepPage.getXML());
Parsing Comma Separated Value files
The CSV (Comma Separated Values) file format is supported by Microsoft Excel and many other programs for simple interchange of flat-file data. If your application needs to import data from CSV files, your Service File rules can use a Parse Delimited rule. For an example, see the Pega Community article How to parse a Comma-Separated-Values (CSV) file using a file service.
Accepting completed PDF forms
A Service File rule can accept arriving PDF form documents completed by customers, Web site visitors, or other sources, and use a Parse Structured rule ( Rule-Parse-Structured rule type) to copy the form to the clipboard. An activity can then extract the completed form fields from the PDF form.
See the Pega Community article Working with PDF forms and Documents for more information about incoming PDF forms.
You can debug a Service File rule or rules using remote logging. Install the Apache LogFactor5 applet on a workstation and identify this workstation as the target for remote logging in the File Listener form.
Through changes to the
file, you can obtain performance
statistics on the execution of services. See
Performance tool — Statistics for services.
Through settings in the prconfig.xml file, you can be alerted to unusually long service operations. See How to detect lengthy service operations.
As an alternative to updating the prconfig.xml file, you can use dynamic system settings to configure your application. See Using dynamic system settings.
For a Pega Community example of a multithreaded file service, see Pega Community article How to support high-throughput file services with multithreading.