llfix
Low-latency FIX engine
llfix::FixServer< Transport > Class Template Reference

FIX server implementation. More...

#include <fix_server.h>

Inherits Transport, and ManagedInstance.

Public Member Functions

bool create (const std::string &server_name, const std::string server_config_file_path)
 Creates and initialises the FIX server instance. More...
 
bool add_session (const std::string &session_name, FixSessionSettings &session_settings)
 Adds a FIX session using preloaded session settings. More...
 
bool add_session (const std::string &session_config_file_path, const std::string &session_name)
 Adds a FIX session by loading settings from a configuration file. More...
 
bool add_sessions_from (const std::string &session_config_file_path)
 Adds all FIX sessions found in a configuration file. More...
 
std::size_t get_session_count () const
 Returns the number of configured FIX sessions. More...
 
FixSessionget_session (const std::string &session_name) override
 Retrieves a FIX session by name. More...
 
std::string get_session_name (FixSession *session)
 Retrieves the name of a FIX session. More...
 
void get_session_names (std::vector< std::string > &target) override
 Retrieves the names of all configured FIX sessions. More...
 
template<typename... Args>
void specify_repeating_group (Args... args)
 Specify repeating group definitions for incoming FIX messages for all sessions. More...
 
OutgoingFixMessageoutgoing_message_instance (FixSession *session)
 Retrieves the reusable outgoing FIX message instance for a session. More...
 
virtual bool send_outgoing_message (FixSession *session, OutgoingFixMessage *message)
 Encodes and sends an outgoing FIX message. More...
 
void shutdown ()
 Shuts down the FIX server. More...
 
virtual void on_new_order (FixSession *session, const IncomingFixMessage *message)
 Called when a New Order (35=D) message is received. More...
 
virtual void on_cancel_order (FixSession *session, const IncomingFixMessage *message)
 Called when an Order Cancel Request (35=F) message is received. More...
 
virtual void on_replace_order (FixSession *session, const IncomingFixMessage *message)
 Called when an Order Cancel/Replace Request (35=G) message is received. More...
 
virtual void on_application_level_reject (FixSession *session, const IncomingFixMessage *message)
 Called when an application-level reject message is generated. More...
 
virtual void on_session_level_reject (FixSession *session, const IncomingFixMessage *message)
 Called when a session-level reject message is generated. More...
 
virtual void on_custom_message (FixSession *session, const IncomingFixMessage *message)
 Called when any other FIX message type is received. More...
 
virtual void on_logon_request (FixSession *session, const IncomingFixMessage *message)
 Called when a Logon (35=A) request is received from a client. More...
 
virtual void on_logout_request (FixSession *session, const IncomingFixMessage *message)
 Called when a Logout (35=5) request is received from a client. More...
 
virtual void on_client_resend_request (FixSession *session, const IncomingFixMessage *message)
 Called when a Resend Request (35=2) is received from a client. More...
 
virtual void on_client_test_request (FixSession *session, const IncomingFixMessage *message)
 Called when a Test Request (35=1) is received from a client. More...
 
virtual void on_client_heartbeat (FixSession *session)
 Called when a Heartbeat (35=0) message is received from a client. More...
 
virtual bool process_incoming_throttling (FixSession *session, const IncomingFixMessage *incoming_fix_message)
 Applies incoming message throttling logic. More...
 
virtual void process_schedule_validator (FixSession *session)
 Validates the session against configured schedule rules. More...
 
virtual FixSessionaccept_session (std::size_t peer_index, const IncomingFixMessage *incoming_fix_message, const char *buffer, std::size_t buffer_length, uint32_t parser_reject_code)
 Accepts and validates an incoming session before logon processing. More...
 
virtual void process_logon_request (FixSession *session, std::size_t peer_index, const IncomingFixMessage *message)
 Processes an incoming Logon (35=A) request. More...
 
virtual bool authenticate_logon_request (FixSession *session, const IncomingFixMessage *message)
 Authenticates an incoming Logon (35=A) request. More...
 
void set_message_persist_plugin (MessagePersistPlugin *plugin)
 Set the message persistence plugin. More...
 

Protected Member Functions

virtual bool send_heartbeat (FixSession *session, FixString *test_request_id)
 Sends a Heartbeat (35=0) message to the client. More...
 
virtual bool send_logon_response (FixSession *session, const IncomingFixMessage *message)
 Sends a Logon (35=A) response message. More...
 
virtual bool send_logout_message (FixSession *session, const std::string &reason_text="")
 Sends a Logout (35=5) message. More...
 
virtual bool send_test_request (FixSession *session)
 Sends a Test Request (35=1) message. More...
 
virtual bool send_resend_request (FixSession *session)
 Sends a Resend Request (35=2) message. More...
 
virtual bool send_sequence_reset_message (FixSession *session, uint32_t desired_sequence_no)
 Sends a Sequence Reset (35=4) message without gap fill. More...
 
virtual bool send_gap_fill_message (FixSession *session)
 Sends a Gap Fill message in response to a Resend Request. More...
 

Detailed Description

template<typename Transport>
class llfix::FixServer< Transport >

FIX server implementation.

Manages FIX sessions, accepts incoming client connections, routes FIX messages, and provides virtual callbacks for application-level and session-level message handling.

Template Parameters
TransportTransport layer implementation: one of TcpReactor TcpReactorScalable TcpReactorScalableSSL.

Member Function Documentation

◆ accept_session()

template<typename Transport >
virtual FixSession* llfix::FixServer< Transport >::accept_session ( std::size_t  peer_index,
const IncomingFixMessage incoming_fix_message,
const char *  buffer,
std::size_t  buffer_length,
uint32_t  parser_reject_code 
)
inlinevirtual

Accepts and validates an incoming session before logon processing.

Handles parser-level validation failures, checks required header tags, resolves the target session from CompIDs and BeginString, and rejects invalid or duplicate live logon attempts.

Parameters
peer_indexTransport peer index associated with the connection.
incoming_fix_messageParsed incoming FIX message.
bufferRaw incoming FIX bytes for logging/reject context.
buffer_lengthLength of the raw incoming FIX buffer.
parser_reject_codeParser validation result code.
Returns
Pointer to the resolved FIX session, or nullptr if rejected.

◆ add_session() [1/2]

template<typename Transport >
bool llfix::FixServer< Transport >::add_session ( const std::string &  session_config_file_path,
const std::string &  session_name 
)
inline

Adds a FIX session by loading settings from a configuration file.

Parameters
session_config_file_pathPath to the session configuration file.
session_nameName of the session group in the configuration.
Returns
true if the session was added successfully, false otherwise.

◆ add_session() [2/2]

template<typename Transport >
bool llfix::FixServer< Transport >::add_session ( const std::string &  session_name,
FixSessionSettings &  session_settings 
)
inline

Adds a FIX session using preloaded session settings.

Parameters
session_nameLogical name of the session.
session_settingsSession configuration settings.
Returns
true if the session was added successfully, false otherwise.

◆ add_sessions_from()

template<typename Transport >
bool llfix::FixServer< Transport >::add_sessions_from ( const std::string &  session_config_file_path)
inline

Adds all FIX sessions found in a configuration file.

Scans the configuration file for groups containing "SESSION" in their name and creates a FIX session for each.

Parameters
session_config_file_pathPath to the session configuration file.
Returns
true if at least one session was added successfully, false otherwise.

◆ authenticate_logon_request()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::authenticate_logon_request ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Authenticates an incoming Logon (35=A) request.

Allows applications to implement custom authentication logic such as logon usernames and password

Parameters
sessionFIX session attempting to log on.
messageIncoming Logon FIX message.
Returns
true if authentication succeeds, false to reject the logon.

◆ create()

template<typename Transport >
bool llfix::FixServer< Transport >::create ( const std::string &  server_name,
const std::string  server_config_file_path 
)
inline

Creates and initialises the FIX server instance.

Parameters
server_nameLogical name of the FIX server instance.
server_config_file_pathPath to the server configuration file.
Returns
true on successful creation, false on error.

◆ get_session()

template<typename Transport >
FixSession* llfix::FixServer< Transport >::get_session ( const std::string &  session_name)
inlineoverride

Retrieves a FIX session by name.

Parameters
session_nameName of the FIX session.
Returns
Pointer to the FIX session, or nullptr if not found.

◆ get_session_count()

template<typename Transport >
std::size_t llfix::FixServer< Transport >::get_session_count ( ) const
inline

Returns the number of configured FIX sessions.

Returns
Number of active FIX sessions.

◆ get_session_name()

template<typename Transport >
std::string llfix::FixServer< Transport >::get_session_name ( FixSession session)
inline

Retrieves the name of a FIX session.

Parameters
sessionPointer to a FIX session.
Returns
Session name if found, empty string otherwise.

◆ get_session_names()

template<typename Transport >
void llfix::FixServer< Transport >::get_session_names ( std::vector< std::string > &  target)
inlineoverride

Retrieves the names of all configured FIX sessions.

Parameters
targetOutput vector populated with session names.

◆ on_application_level_reject()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_application_level_reject ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when an application-level reject message is generated.

Parameters
sessionFIX session associated with the reject.
messageIncoming FIX message that caused the reject.

◆ on_cancel_order()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_cancel_order ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when an Order Cancel Request (35=F) message is received.

Parameters
sessionFIX session that received the message.
messageIncoming FIX message.

◆ on_client_heartbeat()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_client_heartbeat ( FixSession session)
inlinevirtual

Called when a Heartbeat (35=0) message is received from a client.

Parameters
sessionFIX session that received the heartbeat.

◆ on_client_resend_request()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_client_resend_request ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a Resend Request (35=2) is received from a client.

Parameters
sessionFIX session that received the resend request.
messageIncoming Resend Request FIX message.

◆ on_client_test_request()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_client_test_request ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a Test Request (35=1) is received from a client.

Parameters
sessionFIX session that received the test request.
messageIncoming Test Request FIX message.

◆ on_custom_message()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_custom_message ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when any other FIX message type is received.

Parameters
sessionFIX session that received the message.
messageIncoming FIX message.

◆ on_logon_request()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_logon_request ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a Logon (35=A) request is received from a client.

Parameters
sessionFIX session requesting logon.
messageIncoming Logon FIX message.

◆ on_logout_request()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_logout_request ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a Logout (35=5) request is received from a client.

Parameters
sessionFIX session requesting logout.
messageIncoming Logout FIX message.

◆ on_new_order()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_new_order ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a New Order (35=D) message is received.

Parameters
sessionFIX session that received the message.
messageIncoming FIX message.

◆ on_replace_order()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_replace_order ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when an Order Cancel/Replace Request (35=G) message is received.

Parameters
sessionFIX session that received the message.
messageIncoming FIX message.

◆ on_session_level_reject()

template<typename Transport >
virtual void llfix::FixServer< Transport >::on_session_level_reject ( FixSession session,
const IncomingFixMessage message 
)
inlinevirtual

Called when a session-level reject message is generated.

Parameters
sessionFIX session associated with the reject.
messageIncoming FIX message that caused the reject.

◆ outgoing_message_instance()

template<typename Transport >
OutgoingFixMessage* llfix::FixServer< Transport >::outgoing_message_instance ( FixSession session)
inline

Retrieves the reusable outgoing FIX message instance for a session.

Parameters
sessionTarget FIX session.
Returns
Pointer to the outgoing FIX message instance.

◆ process_incoming_throttling()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::process_incoming_throttling ( FixSession session,
const IncomingFixMessage incoming_fix_message 
)
inlinevirtual

Applies incoming message throttling logic.

Determines whether an incoming FIX message should be processed, delayed, rejected, or cause session termination based on throttling configuration.

Parameters
sessionFIX session receiving the message.
incoming_fix_messageIncoming FIX message.
Returns
true if processing should continue, false otherwise.

◆ process_logon_request()

template<typename Transport >
virtual void llfix::FixServer< Transport >::process_logon_request ( FixSession session,
std::size_t  peer_index,
const IncomingFixMessage message 
)
inlinevirtual

Processes an incoming Logon (35=A) request.

Validates and authenticates the incoming logon, applies heartbeat timing from the request, sends the logon response, and finalises session state transition to logged on.

Parameters
sessionFIX session handling the logon request.
peer_indexTransport peer index associated with the connection.
messageIncoming Logon FIX message.

◆ process_schedule_validator()

template<typename Transport >
virtual void llfix::FixServer< Transport >::process_schedule_validator ( FixSession session)
inlinevirtual

Validates the session against configured schedule rules.

Checks whether the current time is within the session's allowed schedule and terminates the connection if it is not.

Parameters
sessionFIX session to validate.

◆ send_gap_fill_message()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_gap_fill_message ( FixSession session)
inlineprotectedvirtual

Sends a Gap Fill message in response to a Resend Request.

Parameters
sessionFIX session to send the gap fill on.
Returns
true if the message was sent successfully, false otherwise.

◆ send_heartbeat()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_heartbeat ( FixSession session,
FixString *  test_request_id 
)
inlineprotectedvirtual

Sends a Heartbeat (35=0) message to the client.

Parameters
sessionFIX session to send the heartbeat on.
test_request_idOptional TestReqID (tag 112), may be null.
Returns
true if the message was sent successfully, false otherwise.

◆ send_logon_response()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_logon_response ( FixSession session,
const IncomingFixMessage message 
)
inlineprotectedvirtual

Sends a Logon (35=A) response message.

Parameters
sessionFIX session to send the logon response on.
messageIncoming Logon FIX message being responded to.
Returns
true if the message was sent successfully, false otherwise.

◆ send_logout_message()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_logout_message ( FixSession session,
const std::string &  reason_text = "" 
)
inlineprotectedvirtual

Sends a Logout (35=5) message.

Parameters
sessionFIX session to send the logout message on.
reason_textOptional human-readable logout reason.
Returns
true if the message was sent successfully, false otherwise.

◆ send_outgoing_message()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_outgoing_message ( FixSession session,
OutgoingFixMessage message 
)
inlinevirtual

Encodes and sends an outgoing FIX message.

Parameters
sessionTarget FIX session.
messageOutgoing FIX message to send.
Returns
true if the message was sent successfully, false otherwise.

◆ send_resend_request()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_resend_request ( FixSession session)
inlineprotectedvirtual

Sends a Resend Request (35=2) message.

Parameters
sessionFIX session to send the resend request on.
Returns
true if the message was sent successfully, false otherwise.

◆ send_sequence_reset_message()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_sequence_reset_message ( FixSession session,
uint32_t  desired_sequence_no 
)
inlineprotectedvirtual

Sends a Sequence Reset (35=4) message without gap fill.

Parameters
sessionFIX session to send the sequence reset on.
desired_sequence_noTarget sequence number.
Returns
true if the message was sent successfully, false otherwise.

◆ send_test_request()

template<typename Transport >
virtual bool llfix::FixServer< Transport >::send_test_request ( FixSession session)
inlineprotectedvirtual

Sends a Test Request (35=1) message.

Parameters
sessionFIX session to send the test request on.
Returns
true if the message was sent successfully, false otherwise.

◆ set_message_persist_plugin()

template<typename Transport >
void llfix::FixServer< Transport >::set_message_persist_plugin ( MessagePersistPlugin plugin)
inline

Set the message persistence plugin.

Parameters
pluginPointer to a MessagePersistPlugin implementation.

◆ shutdown()

template<typename Transport >
void llfix::FixServer< Transport >::shutdown ( )
inline

Shuts down the FIX server.

Stops the underlying transport and terminates all sessions.

◆ specify_repeating_group()

template<typename Transport >
template<typename... Args>
void llfix::FixServer< Transport >::specify_repeating_group ( Args...  args)
inline

Specify repeating group definitions for incoming FIX messages for all sessions.

Template Parameters
ArgsParameter pack defining repeating group structure.
Parameters
argsRepeating group specification arguments.

Not needed in the commercial edition


The documentation for this class was generated from the following file: