Methods

Description

The Publisher API is invoked by feed handlers to build and process messages. See the section entitled “Use cases for feed handlers” for examples of how a feed handler can use the Publisher API.

The Publisher API uses the template processing module as its source of information about message formats.

Methods




pub_initialize

Description

Initializes the Publisher API. This method must be called before any other API in the Publisher API. This method should be called only once.

Syntax

uint16_t pub_initialize( PUB_STARTUP * startup_settings );

Parameters

PUB_STARTUP * startup_settings

Contains information needed by the publisher in order to initialize.

char * config_dir

The directory in which to locate the publisher.xml file.

char * template_dir

The directory in which to locate RDS templates.

bool strict_check

A value indicating whether strict checking should be performed on messages being built. True indicates that strict checking should be performed. This setting is recommended during development. False indicates that strict checking should not be performed. This setting is recommended in production.

bool own_logger

True if the feed handler has initialized the log file and false if the Publisher should initialize the log file.

char * component_subtype

A value indicating the type of publisher this is. For example, “Fast Feed Handler” or “Demo Feed Handler”. This information is used to identify the type of publisher when displaying information in the Operations Console.

PUB_CALLBACKS * callbacks

Callbacks used to notify the caller of the Publisher API of events. One callback is currently supported, which is a function to call if the Publisher receives a request to shutdown.

The caller of the Publisher API may need to perform shutdown activities that need to occur prior to the shutdown of the Publisher API. The Publisher API invokes this callback function to notify the caller that a request to shut down has been received. The caller is responsible for performing whatever actions need to be taken and then invoke the Publisher's shutdown API.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_beginMessage

Description

Indicates to the Publisher that a new message is being built. This method must be called before setting any of the fields on the message.

Syntax

uint16_t pub_beginMessage( uint16_t message_type,  PUB_SEND_MESSAGE_CONTEXT * msg ).

Parameters

uint16_t message_type

The type of message. This value needs to match the message type indicated in the template.

PUB_SEND_MESSAGE_CONTEXT * msg

The message context for the message being built. This structure must be allocated before calling this method. To build multiple messages at once from multiple threads, allocate several PUB_SEND_MESSAGE_CONTEXT structures and use one per message being simultaneously built.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_cancelMessage

Description

Indicates to the Publisher that a message that was being built is to be cancelled. This method is called after beginMessage to free up any resources being used by the message context.

Syntax

uint16_t pub_cancelMessage( PUB_SEND_MESSAGE_CONTEXT * msg );

Parameters

PUB_SEND_MESSAGE_CONTEXT * msg

The message context for the message being built.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_setField

Description

Sets the value of a field in a message that is being built.

Syntax

uint16_t pub_setInt8Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, int8_t field_value );
uint16_t pub_setInt16Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, int16_t field_value );uint16_t pub_setInt32Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, int32_t field_value );uint16_t pub_setInt64Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, int64_t field_value );uint16_t pub_setUInt8Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint8_t field_value );uint16_t pub_setUInt16Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint16_t field_value );uint16_t pub_setUInt32Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint32_t field_value );uint16_t pub_setUInt64Field( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint64_t field_value );
uint16_t pub_setDecimalField( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, double field_value );

The following method accepts a mantissa (the significant digits) and an exponent. The value of the decimal is mantissa x 10^exponent.

uint16_t pub_setDecimalFieldFromMantissa( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, int64_t mantissa, int8_t exponent );uint16_t pub_setDateField( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint32_t field_value );uint16_t pub_setTimeField( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint32_t field_value );uint16_t pub_setDateTimeField( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uint64_t field_value );uint16_t pub_setStringField( PUB_SEND_MESSAGE_CONTEXT * msg, char * field_name, uchar * field_value);

Parameters

PUB_SEND_MESSAGE_CONTEXT * msg

The message context for the message being built.

char * field_name

The name of the field being set. This name is only used when strict checking is on.

<data type> field_value

The value of the field which is to be placed into the message.

Date values

Express the number of days since year 0000.

Time values

Express the number of microseconds since midnight.

Datetime values

Consist of a 32-bit date value followed by a 32-bit time value.

String values

All string values are in UTF-8 format.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_sendMessage

Description

Sends a market data message. This method may or may not physically send a message. Messages are buffered until a packet is full, and then sent over the network.

Syntax

uint16_t pub_sendMessage( PUB_SEND_MESSAGE_CONTEXT * msg );

Parameters

PUB_SEND_MESSAGE_CONTEXT * msg

The message context for the message being built.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_flush

Description

Sends any buffered market data messages over the network to the subscribers.

Syntax

uint16_t pub_flush( void );

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).




pub_shutdown

Description

Disconnects from the network and discards any resources being used by the Publisher API. This method is called when the feed handler is finished using the Publisher API.

Syntax

uint16_t pub_shutdown( bool flush );

Parameters

bool flush

Indicates whether any buffered messages should be sent before disconnecting.

Returns

uint16_t error_code

An error code or ERR_NONE (value 0).