Apama Documentation : Connecting Apama Applications to External Components : Using Standard Adapters : Using the Apama File Adapter : 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. The definition of FileLine events is as follows:
event FileLine
{
/* The name of the transport being used within the file adapter */
string transportName;
 
/* When receiving these events in response to a request to read
lines, this field will contain the same value as provided in
the corresponding ReadLines event*/
integer requestId;
 
/* The session Id this FileLine event is for or from */
integer sessionId;
 
/* The data as a sequence of strings. */
sequence<string> data;
}
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. The definition of the CloseFile event is as follows:
event CloseFile
{
/* The name of the transport being used within the file adapter */
string transportName;
/* Request ID for this CloseFile event. If an error occurs,
the response will contain this ID */
integer requestId;
 
/* The session ID the file to close is associated with */
integer sessionId;
}
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.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback