Use methods offered by the publisher API that have the feed handler build a message to send to the RAP system.
PUB_CALLBACKS * callbacks;
PUB_STARTUP * startup;
PUB_SEND_MESSAGE_CONTEXT * msg;
uint16_t error_code;
callbacks = Allocate a PUB_CALLBACKS structure;
callbacks->shutdown = &myShutdownEventReceiver;
startup = Allocate a PUB_STARTUP structure;
startup->config_dir = configuration file directory or null;
startup->template_dir = “templates”;
startup->strict_check = false;
startup->component_subtype = “FAST Feed Handler”;
startup->callbacks = callbacks;
startup.version = PUB_STARTUP_VERSION;
pub_initialize( startup );
msg = Allocate a PUB_SEND_MESSAGE_CONTEXT structure;
loop for each message {
error_code = pub_beginMessage( <message_type>, msg );
error_code = pub_setInt32Field( msg, <field_name>, <field_value> );
error_code = pub_setStringField( msg, <field_name>, <field_value> );
error_code = pub_setInt16Field( msg, <field_name>, <field_value> );
error_code = pub_sendMessage( msg );
}
error_code = pub_flush();
error_code = pub_shutdown( false );
Free the PUB_SEND_MESSAGE_CONTEXT structure;
Free the PUB_CALLBACKS structure;
To build multiple messages simultaneously, allocate several PUB_SEND_MESSAGE_CONTEXT structures and use one structure per message. Only one call should initialize the publisher, not one per thread. Similarly, make only a single call to shut down the publisher.
The feed handler does not need to call flush. This call is optional. The shutdown API accepts a Boolean parameter that indicates whether to flush any buffered messages before shutting down.