B2BITS FIX Antenna C++  2.31.0
Public Member Functions | List of all members
Engine::Application Class Referenceabstract

Generic application interface. More...

#include <B2BITS_Application.h>

+ Inheritance diagram for Engine::Application:

Public Member Functions

virtual void onAfterMessageIsParsed (FIXMessage &msg, const Session &sn)
 Fired after incoming message is parsed and stored in storage. More...
 
virtual void onAfterMessageIsReceived (char const *msg, std::size_t msgSize, const Session &sn)
 Fired just after message is received from socket. More...
 
virtual void onAfterMessageIsSent (const AfterMessageIsSentEvent &event, const Session &sn)
 Fired after message is sent to socket. More...
 
virtual void onAsyncConnectCompleted (int error, const Session &sn)
 Fired when async connect operation has completed. More...
 
virtual void onBeforeMessageIsSent (const BeforeMessageIsSentEvent &event, const Session &sn)
 Fired before message is sent to socket. More...
 
virtual void onBeforeMessageIsSent (int msgSeqNum, const Session &sn, std::size_t msgCount)
 Fired before message is sent to socket. More...
 
virtual void onBeforeMessageIsSerialized (FIXMessage &msg, const Session &sn)
 Fired after outgoing message is validated and before it is stored in the storage and sent to socket. 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 onIncomingThrottlerTriggered (const IncomingThrottlerTriggeredEvent &event, const Session &sn)
 Fired when one of the incoming throttlers restriction is met. More...
 
virtual void onInMsgSeqNumTooLowEvent (const InMsgSeqNumTooLowEvent *event, const Session &sn)
 Faired on incoming message with sequence number too low without PossDupFlag set. More...
 
virtual void onInSeqNumChanged (int oldValue, int newValue, const Session &sn)
 Fired just after the incoming seqnum is changed. 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)
 Fired 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 onOutgoingSessionLevelRejectEvent (const OutgoingSessionLevelRejectEvent *event, const Session &sn)
 This call-back method is called when a session-level Reject message (MsgType = 3) is sent. More...
 
virtual void onReconnectTryEvent (int remainTries, const Session &sn)
 This call-back method is called each time session tries to reconnect Callback is called in the scope of the session lock. 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 onSessionLevelRejectWithSeqNumTooHigh (const FIXMessage &msg, const Session &sn)
 Fired 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)
 Fired 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
 A call-back method to process incoming business level 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

◆ ~Application()

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

Destructor.

Member Function Documentation

◆ onAfterMessageIsParsed()

virtual void Engine::Application::onAfterMessageIsParsed ( FIXMessage msg,
const Session sn 
)
inlinevirtual

Fired after incoming message is parsed and stored in storage.

Before any message validation. Callback is called in the scope of the session lock.

Parameters
msgthe incoming message.
snReference to FIX session related to the event.
Note
This callback is fired for FIX sessions only, not for FAST.
Warning
This method should complete as quickly as possible. Do not perform time-consuming tasks inside it.
This callback allows to modify or read an incoming FIX Message before automated validation. Be careful with modifying tags from standard header and trailer.

◆ onAfterMessageIsReceived()

virtual void Engine::Application::onAfterMessageIsReceived ( char const *  msg,
std::size_t  msgSize,
const Session sn 
)
inlinevirtual

Fired just after message is received from socket.

Callback is called in the scope of the session lock.

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

◆ onAfterMessageIsSent()

virtual void Engine::Application::onAfterMessageIsSent ( const AfterMessageIsSentEvent event,
const Session sn 
)
inlinevirtual

Fired after message is sent to socket.

Callback is called NOT in the scope of the session lock.

Parameters
eventInformation about occurred event.
snReference to FIX session related to the event.

◆ onAsyncConnectCompleted()

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.

◆ onBeforeMessageIsSent() [1/2]

virtual void Engine::Application::onBeforeMessageIsSent ( const BeforeMessageIsSentEvent event,
const Session sn 
)
virtual

Fired before message is sent to socket.

Callback is called NOT in the scope of the session lock.

Parameters
eventInformation about occurred event.
snReference to FIX session related to the event.
Note
Default implemenation redirects call to the deprecated overload.

◆ onBeforeMessageIsSent() [2/2]

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

Fired before message is sent to socket.

Designed specifically for benchmarks. Callback is called in the scope of the session lock.

Parameters
[in]msgSeqNumSequence number of the last message to send.
[in]snReference to FIX session related to the event.
[in]msgCountMessages count to send
Deprecated:
This version of the method is deprecated. Use another overload.

◆ onBeforeMessageIsSerialized()

virtual void Engine::Application::onBeforeMessageIsSerialized ( FIXMessage msg,
const Session sn 
)
inlinevirtual

Fired after outgoing message is validated and before it is stored in the storage and sent to socket.

Callback is called in the scope of the session lock.

Parameters
msgthe incoming message.
snReference to FIX session related to the event.
Note
This callback is fired for FIX sessions only, not for FAST.
Warning
This callback allows to modify or read an outgoing FIX Message after automated validation. Be careful with modifying tags from standard header and trailer.

◆ onHeartbeatWithTestReqIDEvent()

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. Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onIncomingThrottlerTriggered()

virtual void Engine::Application::onIncomingThrottlerTriggered ( const IncomingThrottlerTriggeredEvent event,
const Session sn 
)
inlinevirtual

Fired when one of the incoming throttlers restriction is met.

Callback is called in the scope of the session lock.

Parameters
[in]eventInformation about occurred event.
[in]snReference to FIX session related to the event.
Note
The action that the session must do after the callback, can be set by the event.action_ field.
The reason (the 58 tag) for logout and reject messages, can be set by the event.reason_ field.

◆ onInMsgSeqNumTooLowEvent()

virtual void Engine::Application::onInMsgSeqNumTooLowEvent ( const InMsgSeqNumTooLowEvent event,
const Session sn 
)
inlinevirtual

Faired on incoming message with sequence number too low without PossDupFlag set.

If message is processed, InMsgSeqNumTooLowEvent::processed_ should be set to true; otherwise session will be stopped.

◆ onInSeqNumChanged()

virtual void Engine::Application::onInSeqNumChanged ( int  oldValue,
int  newValue,
const Session sn 
)
inlinevirtual

Fired just after the incoming seqnum is changed.

Parameters
oldValueold incoming sequence number
newValuenew incoming sequence number
snReference to FIX session related to the event.
Note
This callback is fired for FIX sessions only, not for FAST.

◆ onInvalidResendRequestEvent()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onLogonEvent()

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.

Callback is called in the scope of the session lock.

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.

◆ onLogoutEvent()

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.

In case of session disconnect, LogoutEvent::m_pLogoutMsg is null.

Callback is called in the scope of the session lock.

Note
It is prohibited to call Session::connect inside this callback. To restart the session user should create new thread and call Session::connect there. Also, to the restart session event->LogoutEvent::reconnectFlag_ = true may be set.
Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onMessagePreparedForSending()

virtual void Engine::Application::onMessagePreparedForSending ( const FIXMessage msg,
const Session sn 
)
inlinevirtual

Fired when message is prepared for sending to socket.

Callback is called in the scope of the session lock.

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

◆ onMsgRejectEvent()

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

◆ onNewStateEvent()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onOutgoingSessionLevelRejectEvent()

virtual void Engine::Application::onOutgoingSessionLevelRejectEvent ( const OutgoingSessionLevelRejectEvent event,
const Session sn 
)
inlinevirtual

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

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onReconnectTryEvent()

virtual void Engine::Application::onReconnectTryEvent ( int  remainTries,
const Session sn 
)
inlinevirtual

This call-back method is called each time session tries to reconnect Callback is called in the scope of the session lock.

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

◆ onResend()

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. Callback is called in the scope of the session lock.

Parameters
msgOutgoing message.
snFIX session.
Returns
true if the message should be resent, otherwise false.

◆ onResendRequestEvent()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onResendRequestLoop()

virtual bool Engine::Application::onResendRequestLoop ( const ResendRequestEvent event,
const Session sn 
)
inlinevirtual

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

Callback is called in the scope of the session lock.

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

◆ onSequenceGapEvent()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onSessionLevelRejectEvent()

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.

◆ onSessionLevelRejectWithSeqNumTooHigh()

virtual bool Engine::Application::onSessionLevelRejectWithSeqNumTooHigh ( const FIXMessage msg,
const Session sn 
)
inlinevirtual

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

Callback is called in the scope of the session lock.

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.

◆ onSwitchConnectionEvent()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onTerminated()

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

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

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

◆ onUnableToRouteMessage()

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.

Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ onUnexpectedMessageEvent()

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. Callback is called in the scope of the session lock.

Parameters
eventInformation about occurred event.
snThe corresponding FIX session.

◆ process()

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

A call-back method to process incoming business level messages.

If the application can not process the given message, the FIX Engine will try to deliver it later according to "Delayed Processing Algorithm".

Callback is called out of the scope of the session lock.

Note
To receive Session Level Reject message please handle Application::onSessionLevelRejectEvent event.
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
true if the application can process the given message, otherwise false.