B2BITS FIX Antenna HFT  1.0.16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Engine::Application Class Referenceabstract

Generic application interface. More...

#include <B2BITS_Application.h>

Public Member Functions

virtual bool onAdminCommand (const Session &sn, const AdminCommand commandCode, const std::string &commandText, std::string &rejectReason)
 Faired when an admin command is received. More...
 
virtual void * onAfterMessageIsReceived (char const *msg, std::size_t msgSize, const Session &sn)
 Faired just after message is received from socket. More...
 
virtual void onAsyncConnectCompleted (int error, const Session &sn)
 Fired when async connect operation has completed. More...
 
virtual void onBeforeLogonIsSerialized (FIXMessage &msg, const Session &sn)
 The callback is called before the Logon message is serialized for sending. More...
 
virtual void onBeforeMessageIsSent (int msgSeqNum, const Session &sn, std::size_t msgCount)
 
virtual bool onBeforeStoreAndForward (const Engine::FIXMessage &fixMsg, char const *msg, size_t msgSize, const Session &sn)
 Faired just before the message is stored to an output log file. More...
 
virtual void onHeartbeatWithTestReqIDEvent (const HeartbeatWithTestReqIDEvent &event, const Session &sn)=0
 This call-back method is called when a Heartbeat message (MsgType = 0) with the TestReqID field (tag = 112) has been received. More...
 
virtual void onInvalidResendRequestEvent (const ResendRequestEvent &event, const Session &sn)
 This call-back method is called when a ill-formed Resend Request (MsgType = 2) has been received. More...
 
virtual void onLogonEvent (const LogonEvent *event, const Session &sn)=0
 This call-back method is called to notify that the Logon message has been received from the counterpart. More...
 
virtual void onLogoutEvent (const LogoutEvent *event, const Session &sn)=0
 This call-back method is called to notify that the Logout message has been received from the counterpart or the session was disconnected. More...
 
virtual void onMessagePreparedForSending (const FIXMessage &msg, const Session &sn)
 Faired when message is prepared for sending to socket. More...
 
virtual void onMsgRejectEvent (const MsgRejectEvent *event, const Session &sn)=0
 This call-back method is called when a message have to be rejected. More...
 
virtual void onNewStateEvent (const NewStateEvent &event, const Session &sn)=0
 This call-back method is called when the session has changed its state. More...
 
virtual void onReconnectTryEvent (int remainTries, const Session &sn)
 This call-back method is called each time session tries to reconnect. More...
 
virtual bool onResend (const FIXMessage &msg, const Session &sn)=0
 This call-back method is called when an outgoing message is about to be resent as a reply to the incoming ResendRequest message. More...
 
virtual void onResendRequestEvent (const ResendRequestEvent &event, const Session &sn)=0
 This call-back method is called when a Resend Request (MsgType = 2) has been received. More...
 
virtual bool onResendRequestLoop (const ResendRequestEvent &event, const Session &sn)
 This call-back method is called when #DuplicateResendRequestLimit ResendRequest messages are received. More...
 
virtual void onSequenceGapEvent (const SequenceGapEvent *event, const Session &sn)=0
 This call-back method is called when a message gap is detected in incoming messages. More...
 
virtual void onSessionLevelRejectEvent (const SessionLevelRejectEvent *event, const Session &sn)=0
 This call-back method is called when a session-level Reject message (MsgType = 3) is received. More...
 
virtual bool onSessionLevelRejectEvent (Engine::FIXMessageProcessElem *work, const Session &sn)
 This call-back method is called when a session-level Reject message (MsgType = 3) is received. More...
 
virtual bool onSessionLevelRejectWithSeqNumTooHigh (const FIXMessage &msg, const Session &sn)
 Faired when Session Level Reject message is received with the sequence number too high. More...
 
virtual void onSwitchConnectionEvent (const SwitchConnectionEvent &event, const Session &sn)
 This call-back method is called when the session is switching to another connection. More...
 
virtual void onTerminated (const Session &sn)
 Faired when Session is terminated and all internal threads are stopped. More...
 
virtual void onUnableToRouteMessage (const UnableToRouteMessageEvent &event, const Session &sn)=0
 This call-back method is called when the message has to be routed to the session, which does not exist. More...
 
virtual void onUnexpectedMessageEvent (const UnexpectedMessageEvent *event, const Session &aSn)
 This call-back method is called to notify about received unexpected message. More...
 
virtual bool process (const FIXMessage &msg, const Session &sn)=0
 The call-back method to process incoming messages. More...
 
virtual bool process (Engine::FIXMessageProcessElem *work, const Engine::Session &sn)
 The call-back method to process incoming messages. More...
 
virtual ~Application ()
 Destructor. More...
 

Detailed Description

Generic application interface.

Processes the incoming messages. All user's applications must be inherited from this class.

Constructor & Destructor Documentation

virtual Engine::Application::~Application ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual bool Engine::Application::onAdminCommand ( const Session sn,
const AdminCommand  commandCode,
const std::string &  commandText,
std::string &  rejectReason 
)
inlinevirtual

Faired when an admin command is received.

Parameters
[in]snis a reference to a session, the admin command refers to
[in]commandCodeis a code of the admin command
[in]commandTextis a text representation of the command
[out]rejectReasonis a short description why the command is rejected
Returns
false if the command must be rejected, otherwise true
virtual void* Engine::Application::onAfterMessageIsReceived ( char const *  msg,
std::size_t  msgSize,
const Session sn 
)
inlinevirtual

Faired just after message is received from socket.

Parameters
[in]snReference to FIX session related to the event.
[in]msgPointer to the buffer with message.
[in]msgSizeSize of the message buffer.

References B2B_USE_ARG.

virtual void Engine::Application::onAsyncConnectCompleted ( int  error,
const Session sn 
)
inlinevirtual

Fired when async connect operation has completed.

Callback is called in the scope of the session lock.

Parameters
[in]errorError code of the connect operation, 0 means no error
[in]snReference to FIX session related to the event.
virtual void Engine::Application::onBeforeLogonIsSerialized ( FIXMessage msg,
const Session sn 
)
inlinevirtual

The callback is called before the Logon message is serialized for sending.

The callback can be used for Logon message customization.

Parameters
msgLogon message
snReference to FIX session sending the Logon message.

References B2B_USE_ARG.

virtual void Engine::Application::onBeforeMessageIsSent ( int  msgSeqNum,
const Session sn,
std::size_t  msgCount 
)
inlinevirtual
Note
Currently disabled.

The callback is called before the message is sent to socket. Designed specifically for benchmarks.

Parameters
msgSeqNumSequence number of the sent message.
snReference to FIX session related to the event.
msgCountMessages count to send

References B2B_USE_ARG.

virtual bool Engine::Application::onBeforeStoreAndForward ( const Engine::FIXMessage fixMsg,
char const *  msg,
size_t  msgSize,
const Session sn 
)
inlinevirtual

Faired just before the message is stored to an output log file.

Returns
true if the message should be sent, otherwise false.
virtual void Engine::Application::onHeartbeatWithTestReqIDEvent ( const HeartbeatWithTestReqIDEvent event,
const Session sn 
)
pure virtual

This call-back method is called when a Heartbeat message (MsgType = 0) with the TestReqID field (tag = 112) has been received.

Usually such a message is sent in reply to a Test Request (MsgType = 1) message.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual void Engine::Application::onInvalidResendRequestEvent ( const ResendRequestEvent event,
const Session sn 
)
inlinevirtual

This call-back method is called when a ill-formed Resend Request (MsgType = 2) has been received.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

References B2B_USE_ARG.

virtual void Engine::Application::onLogonEvent ( const LogonEvent event,
const Session sn 
)
pure virtual

This call-back method is called to notify that the Logon message has been received from the counterpart.

If std::exception is raised inside this event, incoming connection will be closed. Exception text will be stored to the engine.log file.

Parameters
eventEvent information.
snThe corresponding FIX session.
virtual void Engine::Application::onLogoutEvent ( const LogoutEvent event,
const Session sn 
)
pure virtual

This call-back method is called to notify that the Logout message has been received from the counterpart or the session was disconnected.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual void Engine::Application::onMessagePreparedForSending ( const FIXMessage msg,
const Session sn 
)
inlinevirtual

Faired when message is prepared for sending to socket.

Note
Available if ENABLE_FAILOVER_CLUSTER_API is on.
Parameters
[in]messagePrepared message.
[in]snReference to FIX session related to the event.

References B2B_USE_ARG.

virtual void Engine::Application::onMsgRejectEvent ( const MsgRejectEvent event,
const Session sn 
)
pure virtual

This call-back method is called when a message have to be rejected.

Parameters
event- object that encapsulates rejected message
sn- session object that rejects message
virtual void Engine::Application::onNewStateEvent ( const NewStateEvent event,
const Session sn 
)
pure virtual

This call-back method is called when the session has changed its state.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual void Engine::Application::onReconnectTryEvent ( int  remainTries,
const Session sn 
)
inlinevirtual

This call-back method is called each time session tries to reconnect.

Parameters
remainTriesThe remain reconnect tries count.
snThe corresponding FIX session.

References B2B_USE_ARG.

virtual bool Engine::Application::onResend ( const FIXMessage msg,
const Session sn 
)
pure virtual

This call-back method is called when an outgoing message is about to be resent as a reply to the incoming ResendRequest message.

If the method returns 'true' then the Engine resends the message to counterpart, otherwise it sends the SequenceReset Gap Fill message.

Parameters
msgOutgoing message.
snFIX session.
Returns
true if the message should be resent, otherwise false.
virtual void Engine::Application::onResendRequestEvent ( const ResendRequestEvent event,
const Session sn 
)
pure virtual

This call-back method is called when a Resend Request (MsgType = 2) has been received.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual bool Engine::Application::onResendRequestLoop ( const ResendRequestEvent event,
const Session sn 
)
inlinevirtual

This call-back method is called when #DuplicateResendRequestLimit ResendRequest messages are received.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
Returns
To reset #DuplicateResendRequestLimit counter return true; false otherwise.

References B2B_USE_ARG.

virtual void Engine::Application::onSequenceGapEvent ( const SequenceGapEvent event,
const Session sn 
)
pure virtual

This call-back method is called when a message gap is detected in incoming messages.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual void Engine::Application::onSessionLevelRejectEvent ( const SessionLevelRejectEvent event,
const Session sn 
)
pure virtual

This call-back method is called when a session-level Reject message (MsgType = 3) is received.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual bool Engine::Application::onSessionLevelRejectEvent ( Engine::FIXMessageProcessElem work,
const Session sn 
)
virtual

This call-back method is called when a session-level Reject message (MsgType = 3) is received.

If the application can not process the given message, the FIX Engine will try to deliver it later. If the callee hasn't commited the message into the session's log the engine will commit it when the call-back returns.

Warning
This method should complete as quickly as possible. Do not perform time-consuming tasks inside it.
Parameters
workthe incoming message and the additional message processing related information.
snThe corresponding FIX session.
Returns
true if the application can process the given message right now, otherwise false to delay (throttle).
virtual bool Engine::Application::onSessionLevelRejectWithSeqNumTooHigh ( const FIXMessage msg,
const Session sn 
)
inlinevirtual

Faired when Session Level Reject message is received with the sequence number too high.

Note
It can occur when remote site sends reject on Resend Request. In this case user can reset incoming/outgoing sequences and restart the session.
Returns
true if message is processed; false [default] to send resend request message.

References B2B_USE_ARG.

virtual void Engine::Application::onSwitchConnectionEvent ( const SwitchConnectionEvent event,
const Session sn 
)
inlinevirtual

This call-back method is called when the session is switching to another connection.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

References B2B_USE_ARG.

virtual void Engine::Application::onTerminated ( const Session sn)
inlinevirtual

Faired when Session is terminated and all internal threads are stopped.

Parameters
[in]snReference to FIX session related to the event.

References B2B_USE_ARG.

virtual void Engine::Application::onUnableToRouteMessage ( const UnableToRouteMessageEvent event,
const Session sn 
)
pure virtual

This call-back method is called when the message has to be routed to the session, which does not exist.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.
virtual void Engine::Application::onUnexpectedMessageEvent ( const UnexpectedMessageEvent event,
const Session aSn 
)
inlinevirtual

This call-back method is called to notify about received unexpected message.

For example - when first message in session is not a Logon.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

References B2B_USE_ARG.

virtual bool Engine::Application::process ( const FIXMessage msg,
const Session sn 
)
pure virtual

The call-back method to process incoming messages.

If an exception is thrown from the callback the reject message will be sent.

Warning
This method should complete as quickly as possible. Do not perform time-consuming tasks inside it.
Parameters
msgthe incoming message.
snThe corresponding FIX session.
Returns
the value is ignored. Please note that the message is lost if application can't process it in place and can't queue it to some internal queue for delayed processing.
virtual bool Engine::Application::process ( Engine::FIXMessageProcessElem work,
const Engine::Session sn 
)
virtual

The call-back method to process incoming messages.

If the application can not process the given message, the FIX Engine will try to deliver it later. If an exception is thrown from the callback the reject message will be sent. If the callee hasn't commited the message into the session's log the engine will commit it when the call-back returns.

Warning
This method should complete as quickly as possible. Do not perform time-consuming tasks inside it.
Parameters
workthe incoming message and the additional message processing related information.
snThe corresponding FIX session.
Returns
true if the application can process the given message right now, otherwise false to delay (throttle). Please note that throttling is not supported if the message is delivered from out-of-sequence queue
See Also
OutOfSequenceMessagesStrategy So the message must be processed in place or some application level queueing be used.