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

FIX client implementation. More...

#include <fix_client.h>

Inherits Transport, and ManagedInstance.

Public Member Functions

bool create (const std::string &client_name, const FixClientSettings &settings, const std::string &session_name, const FixSessionSettings &session_settings)
 Create and initialise a FIX client instance. More...
 
bool create (const std::string &client_config_file_path, const std::string &client_name, const std::string &session_config_file_path, const std::string &session_name)
 Create and initialise a FIX client using configuration files. More...
 
FixSessionget_session (const std::string &session_name="") override
 Retrieve the FIX session managed by this client. More...
 
template<typename... Args>
void specify_repeating_group (Args... args)
 Specify repeating group definitions for incoming FIX messages. More...
 
bool start ()
 Start the client execution thread. More...
 
bool connect ()
 Establish a FIX network connection and initiate logon. More...
 
void process ()
 Process incoming and outgoing FIX protocol activity. More...
 
void shutdown (bool graceful_shutdown=true)
 Shutdown the FIX client. More...
 
OutgoingFixMessageoutgoing_message_instance ()
 Obtain a reusable outgoing FIX message instance. More...
 
virtual bool send_outgoing_message (OutgoingFixMessage *message)
 Encode and send an outgoing FIX message. More...
 
bool connected_to_primary () const
 Check if the client is connected to the primary endpoint. More...
 
bool connected_to_secondary () const
 Check if the client is connected to the secondary endpoint. More...
 
virtual void on_connection ()
 Called when a TCP connection is successfully established.
 
virtual void on_disconnection ()
 Called when the TCP connection is lost or closed.
 
virtual void on_logon_response (const IncomingFixMessage *message)
 Called upon receiving a successful FIX Logon response. More...
 
virtual void on_logout_response (const IncomingFixMessage *message)
 Called upon receiving a FIX Logout response. More...
 
virtual void on_logon_reject (const IncomingFixMessage *message)
 Called when a FIX Logon is rejected. More...
 
virtual void on_server_heartbeat ()
 Called upon receiving a FIX Heartbeat from the server.
 
virtual void on_server_test_request (const IncomingFixMessage *message)
 Called upon receiving a FIX Test Request. More...
 
virtual void on_server_resend_request (const IncomingFixMessage *message)
 Called upon receiving a FIX Resend Request. More...
 
virtual void on_execution_report (const IncomingFixMessage *message)
 Called when an Execution Report (35=8) is received. More...
 
virtual void on_order_cancel_replace_reject (const IncomingFixMessage *message)
 Called when an Order Cancel/Replace Reject (35=9) is received. More...
 
virtual void on_session_level_reject (const IncomingFixMessage *message)
 Called on session-level FIX rejects. More...
 
virtual void on_application_level_reject (const IncomingFixMessage *message)
 Called on application-level FIX rejects. More...
 
virtual void on_custom_message_type (const IncomingFixMessage *message)
 Called for other FIX message types. More...
 
void set_message_persist_plugin (MessagePersistPlugin *plugin)
 Set the message persistence plugin. More...
 

Protected Member Functions

virtual bool send_logon_request ()
 Send FIX Logon request. More...
 
virtual bool send_logout_request ()
 Send FIX Logout request. More...
 
virtual bool send_client_heartbeat (FixString *test_request_id)
 Send FIX Heartbeat message. More...
 
virtual bool send_test_request ()
 Send FIX Test Request message. More...
 
virtual bool send_resend_request ()
 Send FIX Resend Request message. More...
 
virtual bool send_sequence_reset_message (uint32_t desired_sequence_no)
 Send FIX Sequence Reset message. More...
 
virtual bool send_gap_fill_message ()
 Send FIX Gap Fill message. More...
 

Detailed Description

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

FIX client implementation.

Template Parameters
TransportTransport layer implementation: one of TCPConnector TCPConnectorTCPDirect TCPConnectorSSL.

FixClient manages a single FIX session lifecycle including connection management, logon/logout, message processing, sequencing, retransmissions, and heartbeats.

The class can run in a dedicated internal thread or be driven externally via repeated calls to process().

Users are expected to derive from FixClient and override virtual callbacks to handle session and application-level FIX messages.

Member Function Documentation

◆ connect()

template<typename Transport >
bool llfix::FixClient< Transport >::connect ( )
inline

Establish a FIX network connection and initiate logon.

Returns
true if connection and logon initiation succeeded, false otherwise.

Attempts connection to the primary endpoint first and falls back to the secondary endpoint if configured.

◆ connected_to_primary()

template<typename Transport >
bool llfix::FixClient< Transport >::connected_to_primary ( ) const
inline

Check if the client is connected to the primary endpoint.

Returns
true if connected to primary, false otherwise.

◆ connected_to_secondary()

template<typename Transport >
bool llfix::FixClient< Transport >::connected_to_secondary ( ) const
inline

Check if the client is connected to the secondary endpoint.

Returns
true if connected to secondary, false otherwise.

◆ create() [1/2]

template<typename Transport >
bool llfix::FixClient< Transport >::create ( const std::string &  client_config_file_path,
const std::string &  client_name,
const std::string &  session_config_file_path,
const std::string &  session_name 
)
inline

Create and initialise a FIX client using configuration files.

Parameters
client_config_file_pathPath to client configuration file.
client_nameClient name inside the config.
session_config_file_pathPath to session configuration file.
session_nameSession name inside the config.
Returns
true on success, false if configuration loading or validation fails.

◆ create() [2/2]

template<typename Transport >
bool llfix::FixClient< Transport >::create ( const std::string &  client_name,
const FixClientSettings &  settings,
const std::string &  session_name,
const FixSessionSettings &  session_settings 
)
inline

Create and initialise a FIX client instance.

Parameters
client_nameLogical name of the FIX client.
settingsClient-level configuration.
session_nameName of the FIX session.
session_settingsSession-level configuration.
Returns
true on successful creation, false otherwise.

◆ get_session()

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

Retrieve the FIX session managed by this client.

Returns
Pointer to the FixSession instance.

◆ on_application_level_reject()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_application_level_reject ( const IncomingFixMessage message)
inlinevirtual

Called on application-level FIX rejects.

Parameters
messageIncoming reject message.

◆ on_custom_message_type()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_custom_message_type ( const IncomingFixMessage message)
inlinevirtual

Called for other FIX message types.

Parameters
messageIncoming FIX message.

◆ on_execution_report()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_execution_report ( const IncomingFixMessage message)
inlinevirtual

Called when an Execution Report (35=8) is received.

Parameters
messageIncoming execution report message.

◆ on_logon_reject()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_logon_reject ( const IncomingFixMessage message)
inlinevirtual

Called when a FIX Logon is rejected.

Parameters
messageIncoming FIX reject message.

◆ on_logon_response()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_logon_response ( const IncomingFixMessage message)
inlinevirtual

Called upon receiving a successful FIX Logon response.

Parameters
messageIncoming FIX logon message.

◆ on_logout_response()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_logout_response ( const IncomingFixMessage message)
inlinevirtual

Called upon receiving a FIX Logout response.

Parameters
messageIncoming FIX logout message.

◆ on_order_cancel_replace_reject()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_order_cancel_replace_reject ( const IncomingFixMessage message)
inlinevirtual

Called when an Order Cancel/Replace Reject (35=9) is received.

Parameters
messageIncoming reject message.

◆ on_server_resend_request()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_server_resend_request ( const IncomingFixMessage message)
inlinevirtual

Called upon receiving a FIX Resend Request.

Parameters
messageIncoming FIX resend request message.

◆ on_server_test_request()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_server_test_request ( const IncomingFixMessage message)
inlinevirtual

Called upon receiving a FIX Test Request.

Parameters
messageIncoming FIX test request message.

◆ on_session_level_reject()

template<typename Transport >
virtual void llfix::FixClient< Transport >::on_session_level_reject ( const IncomingFixMessage message)
inlinevirtual

Called on session-level FIX rejects.

Parameters
messageIncoming reject message.

◆ outgoing_message_instance()

template<typename Transport >
OutgoingFixMessage* llfix::FixClient< Transport >::outgoing_message_instance ( )
inline

Obtain a reusable outgoing FIX message instance.

Returns
Pointer to an OutgoingFixMessage.

The returned message is owned by the session

◆ process()

template<typename Transport >
void llfix::FixClient< Transport >::process ( )
inline

Process incoming and outgoing FIX protocol activity.

This method drives FIX message handling including:

  • Incoming message parsing
  • Admin command processing
  • Heartbeats and test requests
  • Resend requests and gap fills

Call repeatedly when running without an internal thread.

◆ send_client_heartbeat()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_client_heartbeat ( FixString *  test_request_id)
inlineprotectedvirtual

Send FIX Heartbeat message.

Parameters
test_request_idOptional TestReqID.
Returns
true if sent successfully.

◆ send_gap_fill_message()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_gap_fill_message ( )
inlineprotectedvirtual

Send FIX Gap Fill message.

Returns
true if sent successfully.

◆ send_logon_request()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_logon_request ( )
inlineprotectedvirtual

Send FIX Logon request.

Returns
true if sent successfully.

◆ send_logout_request()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_logout_request ( )
inlineprotectedvirtual

Send FIX Logout request.

Returns
true if sent successfully.

◆ send_outgoing_message()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_outgoing_message ( OutgoingFixMessage message)
inlinevirtual

Encode and send an outgoing FIX message.

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

◆ send_resend_request()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_resend_request ( )
inlineprotectedvirtual

Send FIX Resend Request message.

Returns
true if sent successfully.

◆ send_sequence_reset_message()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_sequence_reset_message ( uint32_t  desired_sequence_no)
inlineprotectedvirtual

Send FIX Sequence Reset message.

Parameters
desired_sequence_noNew sequence number.
Returns
true if sent successfully.

◆ send_test_request()

template<typename Transport >
virtual bool llfix::FixClient< Transport >::send_test_request ( )
inlineprotectedvirtual

Send FIX Test Request message.

Returns
true if sent successfully.

◆ set_message_persist_plugin()

template<typename Transport >
void llfix::FixClient< 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::FixClient< Transport >::shutdown ( bool  graceful_shutdown = true)
inline

Shutdown the FIX client.

Parameters
graceful_shutdownIf true, performs FIX logout handshake.

In threaded mode, this signals the thread to exit. In non-threaded mode, shutdown is performed immediately.

◆ specify_repeating_group()

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

Specify repeating group definitions for incoming FIX messages.

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

Not needed in the commercial edition

◆ start()

template<typename Transport >
bool llfix::FixClient< Transport >::start ( )
inline

Start the client execution thread.

Returns
true if the thread was successfully created, false otherwise.

When started, the client will execute run() in a loop until shutdown is requested.


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