Session Schedule | Table of Content | Failover |
Predefined Schedules and Connection Settings |
To simplify development, the Session Scheduler provides an ability to define session schedules and connection settings in configuration files for later referencing in the source code.
Once presets are defined in the file, the session scheduler can use them during the instance initialization stage (the Scheduler(String) constructor is available for these purposes). Afterwards, both schedules and connection settings can be referenced in source code using the string identifiers. Scheduler exposes the Register(Session, String, String) overload to schedule a session with parameters described in a configuration file.
void RegisterSessionWithPredefinedSettings() { scheduler.Register(sessionWithCurrenex, "Currenex", "Currenex"); }
Private Sub RegisterSessionWithPredefinedSettings() scheduler.Register(sessionWithCurrenex, "Currenex", "Currenex") End Sub
Moreover, Scheduler exposes Schedules and ConnectionSettings properties to access real instances of schedules and connection settings described in the configuration file. These members in helpful when a session has to be registered with partially predefined configuration.
The following example demonstrates how a session can be registered with a predefined schedule, but custom connection settings are not described in the configuration file.
void RegisterSessionWithPartlyDefinedConfiguration() { scheduler.Register( testingEnvironmentSession, scheduler.Schedules["ICE"], new InitiatorConnectingSettings("testing-evironment.ice.com", 8000)); }
Private Sub RegisterSessionWithPartlyDefinedConfiguration() scheduler.Register(testingEnvironmentSession, scheduler.Schedules("ICE"), New InitiatorConnectingSettings("testing-evironment.ice.com", 8000)) End Sub
Sometimes a session's counterparty may be out of service, causing session logon failure. Some systems provide secondary servers, which can be connected while primary servers are down. To support such cases, InitiatorConnectionSettings class exposes the Counterparties property, which allows defining secondary servers, that will be connected in case of the connection failure to the primary server. Also, Scheduler remembers the last good connection settings (counterparty). Therefore, since the next time connection must be established, it will use the last good configuration.
Description of Scheduler settings has XML-based syntax. The following tags are supported:
Tag | Description |
---|---|
SchedulerSettings | Root element of scheduler's configuration. |
Schedules | Contains descriptions of predefined schedules. |
Schedule | Describes attributes of particular session schedule. |
Connections | Contains descriptions of predefined session connection settings. |
Connection | Defines characteristics of particular session connection. |
Note |
---|
Scheduler settings configuration is validated by the schema available on Corporate Website . |
Defining Session Schedule
Session Schedule description consists of the definition of the following attributes for the <Schedule> element:
Attribute | Values | Notes |
---|---|---|
id | Non-empty string. | Unique identifier for the schedule. Value of this attribute is used later in the source code to refer to the described schedule. It must be unique among all schedules. |
firstDay | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". | Defines the first day of the activity week for the session. |
lastDay | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". | Defines the last day of the activity week for the session. |
logonTime | Time value from 0:00 till 23:59 in arbitrary format (12 or 24 hours). | Defines the time of logon for the session. |
logoutTime | Time value from 0:00 till 23:59 in arbitrary format (12 or 24 hours). | Defines the time of logout for the session. |
sessionDuration | "day", "week". | Defines whether a session continues an entire week, or the activity time frame is limited for a single day. |
resetSessionNumber | "never", "daily", "weekly". | Defines session sequence number reset policy. |
Defining Session Connection Settings
Description of connection settings consists of the definition of the following attributes for the <Connection> element:
Attribute | Values | Notes |
---|---|---|
id | Non-empty string. | Unique identifier for the settings set. The value of this attribute is used later in the source code to refer to described settings. It M\must be unique among all settings sets. |
role | "initiator", "acceptor". | Specifies whether the session must be connected as an acceptor or initiator. |
host | String | If a session must be logged on in the role of initiator, this parameter defines a remote host to which the session must connect to. Otherwise, the attribute is ignored. |
port | Number | If a session must be logged on in the role of initiator, this parameter defines a port number to which session must connect to. Otherwise, the attribute is ignored. |
heartbeatInterval | Number | If a session must be logged on in the role of initiator, this parameter defines the time interval between two heartbeat messages sent by the session on connection idle state. |
setResetSeqNumbers | "false", "true" | If a session must be logged on in the role of initiator, this parameter defines whether the session must include a special flag to logon message. In this case, it instructs counterparty to reset session sequence numbers, once the logon procedure is succeeded. |
customLogonMessage | String | Specifies the inline FIX logon message to use. The field delimiter can be specified in the 'customLogonMessageFieldDelimiter' attribute. |
customLogonMessageFieldDelimiter | String | Specifies the field delimiter used in the 'customLogonMessage' attribute. Default value is '|'. |
customLogonMessageFile | String | Specifies the FIX logon message file/resource to use. The field delimiter '0x01' is expected. |
A typical configuration file for the Sessions Scheduler is below.
<?xml version="1.0" encoding="utf-8" ?> <SchedulerSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://ref.onixs.biz/fix/scheduler https://ref.onixs.biz/fix/scheduler/scheduler-settings-1.6.xsd" xmlns="https://ref.onixs.biz/fix/scheduler"> <Schedules> <Schedule id="CME" firstDay="Sunday" logonTime="18:00" lastDay="Friday" logoutTime="16:00" sessionDuration="week" resetSessionNumber="weekly" /> <Schedule id="SimpleDaily" firstDay="Monday" lastDay="Friday" logonTime="08:00" logoutTime="17:00" sessionDuration="day" resetSessionNumber="weekly" /> <Schedule id="SimpleWeekly" firstDay="Monday" lastDay="Friday" logonTime="08:00" logoutTime="17:00" sessionDuration="week" resetSessionNumber="weekly" /> <Schedule id="DailyWithMidnightCross" firstDay="Monday" lastDay="Friday" logonTime="21:00" logoutTime="03:00" sessionDuration="day" resetSessionNumber="daily" /> <Schedule id="WeeklyWithMidnightCross" firstDay="Monday" lastDay="Friday" logonTime="21:00" logoutTime="03:00" sessionDuration="week" resetSessionNumber="never" /> <Schedule id="AllWeek" firstDay="Sunday" lastDay="Saturday" logonTime="0:00" logoutTime="23:59:00" sessionDuration="week" resetSessionNumber="never" /> <Schedule id="DailyWithDailySeqNumberReset" firstDay="Monday" lastDay="Friday" logonTime="8:00" logoutTime="17:00" sessionDuration="day" resetSessionNumber="daily" /> <Schedule id="DailyWithWeeklySeqNumberReset" firstDay="Monday" lastDay="Friday" logonTime="8:00" logoutTime="17:00" sessionDuration="day" resetSessionNumber="weekly" /> </Schedules> <Connections> <Connection id="LocalInitiator" role="initiator" > <Counterparty host="localhost" port="4500"/> </Connection> <Connection id="InitiatorToTestingEnvironment" role="initiator" setResetSeqNumbers="true" > <Counterparty host="testing-evn.privatedomain.com" port="8000"/> </Connection> <Connection id="MultiTargetInitiator" role="initiator" setResetSeqNumbers="true" heartbeatInterval="45"> <Counterparty host="primary.domain.com" port="4600"/> <Counterparty host="secondary.domain.com" port="4500"/> </Connection> <Connection id="InitiatorWithCustomLogonMessage" role="initiator" customLogonMessage="8=FIX.4.2|9=0|35=A|141=Y|5001=TraderId|10=000|" host="localhost" port="4500"> </Connection> <Connection id="InitiatorWithCustomLogonMessageAndFieldDelimiter" role="initiator" customLogonMessage="8=FIX.4.2*9=0*35=A*141=Y*10=000*" customLogonMessageFieldDelimiter="*" host="localhost" port="4500"> </Connection> <!-- Since acceptor has no parameters, there is no need in describing more than one acceptor. --> <Connection id="Acceptor" role="acceptor" /> </Connections> </SchedulerSettings>