Data Mapping Plug-In

The Data Mapping Plug-in converts FIX messages into tuple columns and tuple columns into FIX messages.

The Data Mapping plug-in also performs validations on FIX messages against a database.

The default Data-Mapping Plug-in implementation is designed to match the three Connection Plug-in implementations. It is also highly customizable, and unique implementations can be written using C or C++. When writing a custom Data Mapping Plug-in, include the following functions and ensure that their method signatures match what is given here:

//initialize the Data Mapping plug-in
	C8Bool C8FIXDMInitialize();

	//convert from FIX message to CEP tuple
	C8Message* C8FIXDMConvertToTuple( const void* message, const C8Schema* schema );

	//convert from CEP tuple to FIX message
	void* C8FIXDMConvertToFIX( const C8Message* tuple, char*& session_id, char*& msgtype );

	//convert from raw FIX message to CEP tuple
	C8Message* C8FIXDMConvertFIXRawToTuple( const char* message, const  C8Schema* schema );

	//convert from CEP tuple to a raw FIX message
	char* C8FIXDMConvertTupleToFIXRaw( const C8Message* tuple );

	//properly deallocate a FIX message returned by the C8FIXDMConvertToFIX function
	void C8FIXDMDestroyFIXMessage( void* message );

	//shutdown the Data Mapping plug-in
	C8Bool C8FIXDMShutdown();

The C8FIXDMInitialize() function is called by the FIX Adapter when it starts up. Any initialization required by the plug-in must be performed here.

The C8FIXDMConvertToTuple() function is called by the FIX Adapter after it receives a FIX message from the Connection plug-in and needs to convert it into a tuple before sending it to the CEP server.

The C8FIXDMConvertToFIX() function is called by the FIX Adapter after it receives a tuple from the CEP server and needs to convert the tuple into a FIX message before sending it to the Connection plug-in.

The C8FIXDMConvertFIXRawToTuple() function is called to convert a FIX message in raw (string) format into a CEP tuple. This function is optional.

The C8FIXDMConvertTupleToFIXRaw() function is called to convert a CEP tuple into a FIX message in raw (string) format. This function is optional.

The C8FIXDMDestroyFIXMessage() is called by the FIX Adapter to properly deallocate a FIX message that was previously returned by the C8FIXDMConvertToFIX() function.

The C8FIXDMShutdown() function gets called by the FIX Adapter when the adapter is shutting down. Any clean-up required by the plug-in must be performed here.
Note: When using C++ to write a custom Data Mapping Plug-in, ensure that functions are declared using C-style calling conventions and name mangling.
Note: When writing a custom plug-in, the FIX adapter-related libraries that should be linked to the plug-in are c8_adapter_fix_lib.dll on Windows and libc8_adapters_fix_lib.so on Linux/Solaris.

The Data Mapping plug-in can invoke functions provided by the out-of-process CEP C SDK. When doing so, there is no need to call C8ClientSDKInitialize() and C8ClientSDKShutdown() functions as these have already been called by the FIX Adapter.

The Data Mapping plug-in can also log messages through the FIX Adapter, by calling the following functions (declared in the c8_fix_adapter.h header file installed under the adapters\fix\include directory):
//log messages/errors through the FIX adapter
FIX_ADAPTER_EXPORT void C8FIXLogMessage( C8Int i_err_code, const enum C8LogLevels i_level, const C8Char *i_err_text, ... );
FIX_ADAPTER_EXPORT void C8FIXLogWarning(C8Int i_err_code, const C8Char *i_err_text_id, ...);
FIX_ADAPTER_EXPORT void C8FIXLogError(C8Int i_err_code, const C8Char *i_err_text_id, ...);

The Data Mapping plug-in code should include this header file if these logging functions are to be used.

Custom Settings for the Data Mapping Plug-In

Custom settings for the Data Mapping Plug-in include:

<section name="CustomSettings">
	                <preference name="ValidateFIXMessages">true</preference>
	                <preference name="FIXMessageC8Name">C8_FIXMsgBody</preference>
	                <section name="FieldMappings">
			<preference name="FieldMappingCount">3</preference>
			<!-- Field mapping sections. These must be named FieldMapping1 -->
			<!-- through FieldMappingN, where N corresponds to the -->
			<!-- FieldMappingCount value specified. -->
			<section name="FieldMapping1">
			    <preference name="C8Name">MsgType</preference>
			    <preference name="FIXTag">35</preference>
			</section>
			<section name="FieldMapping2">
			    <preference name="C8Name">SenderCompID</preference>
			    <preference name="FIXTag">49</preference>
			</section>
			<section name="FieldMapping3">
			    <preference name="C8Name">TargetCompID</preference>
			    <preference name="FIXTag">56</preference>
			</section>
	            </section>
	</section>	

The ValidateFIXMessages setting determines if the structure of the FIX message should be validated. If set to true, validation is enabled and FIX messages that do not pass validation are rejected.

The FIXMessageC8Name setting indicates the name of the CEP stream column that will be used to store the entire FIX message (defaults to "C8_FIXMsgBody").

The FieldMappings setting describes the field mapping rules used to map FIX message fields to CEP stream columns.

The FieldMappingCount indicates the number of field mapping rules. If set to 0, field mapping is disabled.

The FieldMapping1 ... FieldMappingN setting pertains to each field mapping rule, where N is the value specified in FieldMappingCount.

The C8Name setting specifies the CEP stream column name.

The FIXTag setting specifies the FIX message field tag.