Writing a Message Handler Plug-in Finalize Function

The message handler plug-in finalize function (ffh_mh_fini_function) for the message handler releases and cleans up any resources used by your message handler plug-in.

  1. Cast the user_data field of the ffh_mh_info to a pointer to your message handling class, if you created one during the initialization.
  2. Invoke the finalize method on the message handler object.
  3. Delete the handler object and set the user_data pointer in ffh_mh_info to null.

Sample finalize function

extern "C" void finalizeHandler( ffh_mh_info * info )
{
    (( FIXMessageHandler*)info->user_data)->finalize();
    delete ( FIXMessageHandler*)info->user_data;
    info->user_data = NULL;
}

void FIXMessageHandler::finalize()
{
    // release Publisher API
    pub_shutdown( true );

    // release other plug-in resources
    if( _msg_ctx != NULL ){
        delete _msg_ctx;
        _msg_ctx = NULL;
    }
    _handlerInfo = NULL;
}
Related concepts
Message Handler Plug-ins
Related tasks
Writing a Message Handler Plug-in for the FAST Feed Handler
Writing a Message Handler Plug-in Initialize Function
Writing a Message Handler Plug-in Process Function
Implementing the Shutdown Callback Method
Related reference
Arguments of the Message Handler Plug-in Initialize Function
Arguments of the Message Handler Process Function
Arguments of the Message Handler Finalize Function
C API Definitions of Function Signatures for Building a Message Handler
C API Definition of ffh_fast_message and its Related Structures
FAST Templates