IAF samples
Your distribution contains two complete examples that demonstrate how the IAF can be used in practice – C and Java implementations of a text file adapter, including build scripts and complete source code.
See
Using Adapter Plug-ins for information about how the sample plug-ins could be used in practice.
The C example
The C example is available in samples\iaf_plugin\c\simple and contains the following:
The complete source code of the
FileTransport transport layer plug-in and the
StringCodec codec plug-in, in the
FileTransport.c and
StringCodec.c files.
The
FileTransport transport layer plug-in can read and write messages from and to a text file. This makes it a useful tool in testing the IAF and the event correlator with files of sample messages.
The
StringCodec codec plug-in can decode messages represented as strings containing a list of field names and values. The configuration properties for the plug-in allow customization of the syntactic characters used as field, name, and message separators (e.g. “
,”, “
=”, “
;”).
A
Makefile for compiling the plug-in sources with GNU Make on UNIX. This builds
libFileTransport.so and
libStringCodec.so, the plug-in binaries.
A ‘workspace’ file and
dsp folder for compiling the plug-in sources with Microsoft’s Visual Studio .NET on Microsoft Windows. The
make.bat batch file can be used to build the Windows plug-in binaries,
FileTransport.dll and
StringCodec.dll.
A sample configuration file,
config.xml. This is an example of an IAF configuration that loads C plug-ins, configures them with plug-in properties, injects a specific EPL file into the event correlator, provides a simple event mapping, and configures the IAF for sending and receiving events to and from the event correlator.
A simple EPL file,
simple.mon. This defines a monitor that examines the incoming events and selectively emits some back out to the IAF.
A text file,
simple-feed.evt, with some test input messages that can be loaded by the File Transport plug-in, parsed by the String Codec plug-in, translated into Apama events by the Semantic Mapper, and then injected into the event correlator.
A reference file,
simple-ref.evt, which shows the expected output file generated when the adapter is run.
To run the example, follow the steps outlined in the README.txt file provided in the samples\iaf_plugin\c\simple folder.
Note: Plug-ins need to be placed in a location where they can be picked up by the event correlator:
On Windows you either need to copy the
.dll into the
bin folder, or else place it somewhere which is on your ‘path’, that is a location that is referenced by the
PATH environment variable.
On UNIX you either need to copy the
.so into the
lib directory, or else place it somewhere which is on your ‘library path’, that is a directory that is referenced by the
LD_LIBRARY_PATH environment variable.
The Java example
The Java example is in the samples\iaf_plugin\java\simple directory, which contains the files:
The complete source code of the
JFileTransport transport layer plug-in and the
JStringCodec codec plug-in, in the
src directory.
The
JFileTransport transport layer plug-in can read and write messages from and to a text file. This makes it a useful tool in testing the IAF and the event correlator with files of sample messages.
In normal operation,
JFileTransport sends
String objects on to the codec for decoding; however by setting the
upstreamNormalised plug-in property it is possible to use the transport plug-in in a different mode in which it also performs the functionality that the codec usually performs (in this case by calling the
JStringCodec class directly). In this mode the transport passes IAF normalized event messages on to the codec plug-in, demonstrating the use of the pass-through
JNullCodec plug-in provided with the Apama distribution.
The
JStringCodec codec plug-in can convert between normalized events and messages represented as strings containing a list of field names and values. The configuration properties for the plug-in allow customization of the syntactic characters used as field, name, and message separators (e.g. “
,”, “
=”, “
;”).
An Apache Ant
build.xml file is included, for compiling the
JFileAdapter.jar binary that contains both plug-ins (and works on all platforms).
A sample configuration file,
config.xml. This is an example of an IAF configuration that loads Java transport and codec plug-ins, configures them with plug-in properties, provides an event mapping, and configures the IAF for sending and receiving events to and from the event correlator.
This configuration file also includes several optional configuration options for logging, custom JVM options, logging of unmapped events/messages, and use of non-standard correlator event batching.
A second configuration file,
config-no-codec.xml that demonstrates how the standard
JNullCodec plug-in can be used with a transport plug-in that incorporates codec functionality itself and produces normalized events directly.
A simple EPL file,
simple.mon. This is identical to the file included with the C sample, and defines a monitor that examines the incoming events and selectively emits some back out to the IAF.
A text file,
simple-feed.evt. This is identical to the file included with the C sample, and contains some test input messages that can be loaded by the File Transport plug-in, parsed by the String Codec plug-in, translated into Apama events by the Semantic Mapper, and then injected into the event correlator.
A reference file,
simple-ref.evt, which shows the expected output file generated when the adapter is run. Note that this file is (only trivially) different to the reference file for the C plug-ins.
To run the example, follow the steps outlined in the README.txt file provided in the samples\iaf_plugin\java\simple folder.