The plug-in initialize function (ffh_mh_init_function) for the message handler prepares the plug-in for use.
For example, you can create an instance of a message handling class and store the pointer to this instance in the info->user_data member. You can use that pointer later to invoke your class from the ffh_mh_fini_function and the ffh_mh_process_function functions.
extern "C“ int32_t initializeHandler( ffh_mh_info * info, ffh_init_param * initParams, int32_t initParamLen ) { info->user_data = new FIXMessageHandler(); return (( FIXMessageHandler* ) info->user_data)->initialize( info, initParams, initParamLen ); } int32_t FIXMessageHandler::initialize( ffh_mh_info * info, ffh_init_param * initParams, int32_t initParamLen ) { // initialize the logger by using external context log_init_from_context( info->loggerCtx ); // initialize Publisher API PUB_STARTUP startupSettings; startupSettings.component_subtype = "FAST Feed Handler"; startupSettings.strict_check = false; startupSettings.own_logger = true; startupSettings.callbacks.shutdown = publisherShutdown; for( int i = 0; i < initParamLen; i++ ) { if( strcmp( initParams[i].name, "PublisherConfigDir" ) == 0 ) { startupSettings.config_dir = initParams[i].value; } else if( strcmp( initParams[i].name, "RDSTemplateDir" ) == 0 ) { startupSettings.template_dir = initParams[i].value; } } int32_t error_code = pub_initialize( &startupSettings ); if( error_code != ERR_NONE ) { log_message( LOGGER_ERROR, error_code, “Initialization failed." ); return error_code; } // create Publisher API message context _msg_ctx = new PUB_SEND_MESSAGE_CONTEXT(); // store the ffh_mh_info so that it can be used // by publisherShutdown() setHandlerInfo( info ); return ERR_NONE; }
where:
Returns:
int32_t 0 if the initialization succeeded; otherwise, a nonzero error code.