The Publisher API offers your methods that allow the feed handler to build a message to be sent to the Sybase RAP system. After initializing the Publisher API, do the following to build a message:
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;
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 at once, allocate several PUB_SEND_MESSAGE_CONTEXT
structures
and use one structure per message being simultaneously built. Only
one call should be made to initialize the Publisher, not one per
thread. Similarly, only a single call should be made 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 which indicates whether to flush any buffered messages before shutting down.