Programming Guide
Introduction
In real life, FIX connections occur at regular intervals. A lot of trading systems have public schedules which declare time frames for trading. The biz.onixs.fix.engine.Session object exposes members for basic FIX connection handling. It also provides users with an automatic reconnection facility in case of connection failure. However, there is no way in the session functionality to maintain connections on a systematic basis.
To satisfy the needs of real‑life trading schedules, the session scheduler component is offered. This service will automatically connect certain FIX sessions to the counterparty at the beginning of the trading day as well as disconnect them at the end of the day. It is also possible to keep a FIX session connected for an entire trading week and disconnect it at the end of the last trading day.
Main Class
The biz.onixs.fix.scheduler.SessionScheduler class is the workhorse of the sessions scheduler component.
This class exposes a simple but comprehensive API to handle connections by schedules of any complexity.
Registering a Session
The biz.onixs.fix.scheduler.SessionScheduler.register(Session, SessionSchedule, SessionConnection) method schedules a session for automatic logon and logout according to the specified session schedule.
Note: If a session is registered at a time that matches the schedule, the scheduler will connect the session immediately.
Un-registering a Session
The biz.onixs.fix.scheduler.SessionScheduler.unregister(Session) method removes the specified session from the scheduling service.
Note: The unregister method doesn't disconnect the active session from the trading system. Therefore, if a session was already connected by the scheduler, it remains connected after unregistering.
Error Notification
The scheduler accepts the biz.onixs.fix.scheduler.ErrorListener event listener to deliver notifications about errors in session management.
Programmatic Configuration
There are different session schedule implementation classes.
Single-day and Multi-day Schedule
The first two parameters (firstDay and lastDay) define the activity week. During these days the session will always be connected at logon time and disconnected at logout time if the specified session duration equals a single day. If the session must continue for several days, then the scheduler will connect the session at logon time on the day specified by the firstDay parameter and disconnect it at logout time on the day specified by the lastDay parameter.
The logonTime and logoutTime parameters respectively define the time of logon and logout for the session for each activity day if the session duration is a single day. If the session must continue for the entire week, then the logonTime parameter value specifies the time for logon to be performed on the first day of the activity week and the logoutTime parameter value defines the time of logout performed on the last day of the activity week.
Finally, the resetPolicy parameter specifies whether the session sequence numbers must be reset and on which basis (never, daily or weekly).
Reset on Every Connection
In some operational scenarios, the scheduled connection must always start as a fresh FIX session — regardless of whether it is the first scheduled logon or a reconnection after a transport‑level failure (such as a TCP error).
To achieve this:
- Send a Logon with
ResetMsgSeqNumFlag=Y
(tag 141) on every connection. setSetResetSeqNumbers(true)
adds the flag to the initial engine‑initiated Logon only.- For reconnects after TCP errors, configure a custom Logon to also include
141=Y
and ensure these settings are reapplied before each reconnect attempt.
Example FIX 4.4 Logon:
8=FIX.4.4|9=***|35=A|34=1|49=SENDER|56=TARGET|98=0|108=30|141=Y|10=***|
Example using biz.onixs.fix.scheduler.InitiatorConnection:
InitiatorConnection ic = new InitiatorConnection();
ic.setCustomLogonMessageFieldDelimiter("|");
ic.setCustomLogonMessage("8=FIX.4.4|9=***|35=A|34=1|49=SENDER|56=TARGET|98=0|108=30|141=Y|10=***|");
ic.setSetResetSeqNumbers(true); // for initial scheduled logon
File-based Configuration
To simplify development, the session scheduler provides an option to define session schedules and connection settings in a configuration file for later referencing in the source code.
The presets defined in the configuration file can be loaded using biz.onixs.fix.scheduler.SchedulerSettingsLoader class. Then both schedules and connection settings can be referenced in the source code using string identifiers.
Configuration File Reference
The configuration file has an XML‑based format. The appropriate XML schema is available here.
Samples
Check also Samples :: Scheduler.
Quartz Configuration
Session scheduler uses Quartz Scheduler library internally.
During session scheduler start the Quartz is configured using bundled OnixS default Quartz configuration file:
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 10
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
org.quartz.jobStore.misfireThreshold: 60000
org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
org.quartz.scheduler.skipUpdateCheck: true
This configuration file is located inside the session scheduler JAR.
Custom Quartz configuration file can be provided via biz.onixs.fix.scheduler.SessionScheduler.setQuartzConfigFile(String) method.
Quartz configuration reference is here.