Apama 10.15.5 | Connecting Apama Applications to External Components | Standard IAF Plug-ins | The File IAF Adapter (JMultiFileTransport) | Specifying file names in OpenFileForReading events
 
Specifying file names in OpenFileForReading events
In an OpenFileForReading event, the value of the filename field can be a specific file name or a wildcard pattern. However, the filename cannot have multiple wildcards.
Specific filename
When you specify a specific filename in an OpenFileForReading event, when the adapter receives requests to read lines from the file, the adapter reads till the end of the file and waits until more data is available. An external process, or the adapter itself, might write more data to the file if it is open for write at the same time that it is being read. If more data becomes available, the File adapter sends it. If the File adapter receives a CloseFile event, the File adapter closes the file against further reading.
Each time the File adapter reaches the end of the file it is reading, the File adapter sends an EndOfFile event to the correlator. If, during this process, more data was appended to the file, the file operations will continue as normal — that is, the File adapter will send more lines if they were requested. Thus, when reading specific files, file appends are acceptable and have a well defined behavior. However, any other modifications, such as changing the lines that have already been read, may have undefined results. An application can ignore or react to an EndOfFile event. See the com.apama.file package in the API Reference for EPL (ApamaDoc) for detailed information on the EndOfFile event.
Wildcard filenames
Now suppose that in an OpenFileForReading event, the value of the filename field is a wildcard pattern. In this case, the adapter does the following:
1. Opens a new file that matches the pattern
2. Reads that file in its entirety
3. Sends back an EndOfFile event
4. Opens the next file that matches the pattern if one is available
For the application's information, the File adapter sends back an event when it opens each new file. The NewFileOpened event contains the name of the file that was opened. See the com.apama.file package in the API Reference for EPL (ApamaDoc) for detailed information on the NewFileOpened event.
The order of opening the files that match the wildcard pattern is not specified. Currently, the files are ordered by the modification date and then alphabetically by filename.
If a file that has been previously read is externally modified (while in the meantime, the File adapter is reading from other files that match the wildcard pattern), the file is read again in its entirety. That is, any files that are modified after reading from them will be read again (until the CloseFile is sent). Note that this includes file appends.