Apama 10.15.5 | Connecting Apama Applications to External Components | Standard IAF Plug-ins | The File IAF Adapter (JMultiFileTransport) | Receiving data
 
Receiving data
As the File adapter reads the file, it returns FileLine events to your application. Each line is associated with a specific sessionId, and the data is stored within a sequence of strings. See the com.apama.file package in the API Reference for EPL (ApamaDoc) for detailed information on the FileLine event.
Notice that the data field is a sequence of strings, rather than a string. However, when you use the null codec for reading, the sequence contains only one element, which contains the entire line read:
//the whole line is stored in the first element, we used null codec
string line := fileLine.data[0];
For specialized codecs, each field is in a discrete element in the sequence:
//The app knows which field contains the data we are interested in:
string symbol := fileLine.data[0];
string exchange := fileLine.data[1];
string currentprice := fileLine.data[2];
//and so on
After the File adapter opens a file for reading, the file remains open as long as the adapter is running. If you want to close a file, you must send a CloseFile event that specifies the sessionId of the file you want to close. For example, if you want to replace the contents of a file, you must close the file before you send an OpenFileForWriting event. See the com.apama.file package in the API Reference for EPL (ApamaDoc) for detailed information on the CloseFile event.
If there is an error, the File adapter sends a FileError event. Otherwise, the File adapter closes the file and sends a FileClosed event, and then it is available to be opened again for writing or for reading.