Programming Guide
- Programming Guide
Introduction
The Session Scheduler service provides an automated way to manage session connectivity according to predefined trading schedules.
It connects sessions to their counterparties at the beginning of a trading day or week, keeps them connected during active hours, and disconnects them at the end of the trading period.
While the biz.onixs.cme.ilink3.handler.Session object offers basic connection management and automatic reconnection on failures, it does not maintain connections systematically according to trading calendars.
The scheduler fills this gap, ensuring sessions follow real-world exchange connectivity requirements.
Main Class
The biz.onixs.cme.ilink3.scheduler.SessionScheduler class is the core component of the scheduling service.
It provides a high-level API for managing connections according to trading schedules of any complexity.
Registering a Session
The biz.onixs.cme.ilink3.scheduler.SessionScheduler.register(Session, SessionSchedule, SessionConnection) method registers a session for automatic logon and logout according to a specified schedule.
Note:
If a session is registered during a time that falls within its active period, the scheduler connects the session immediately.
Unregistering a Session
The biz.onixs.cme.ilink3.scheduler.SessionScheduler.unregister(Session) method removes the specified session from the scheduler.
Note:
Unregistering a session does not disconnect an active connection. If the session was connected by the scheduler, it will remain connected until explicitly logged out.
Error Notification
The scheduler supports the biz.onixs.cme.ilink3.scheduler.ErrorListener interface for error handling and notifications.
Listeners can subscribe to receive error callbacks when connection or scheduling issues occur.
Scheduler Algorithm
The scheduler’s behavior can be described by the following simplified algorithm:
-
Determine Active Sessions
Evaluate the registered schedules to determine which sessions should be active based on the current date and time. -
Connect Sessions
For each session whose schedule indicates an active period:- If the session is disconnected, attempt to connect.
- If a connection attempt fails, retry according to the scheduler retry policy configured via
setConnectionRetriesNumber(...)andsetConnectionRetriesInterval(...).
-
Maintain Connections
Keep each active session connected for its entire scheduled duration.
The scheduler monitors connection states and automatically reconnects if a disconnection occurs within the active time window. -
Disconnect Sessions
When a session’s active period ends, the scheduler gracefully logs it out and closes the TCP connection. -
Repeat Continuously
The scheduler runs continuously, monitoring schedules and adjusting connections automatically as time progresses.
This approach ensures robust, fully automated session lifecycle management aligned with trading calendars.
Programmatic Configuration
Several session schedule implementations are provided to define daily or multi-day trading behavior.
Single-day and Multi-day Schedule
The first two parameters, firstDay and lastDay, define the active trading week.
During these days:
- If a session’s duration is a single day, it connects at
logonTimeand disconnects atlogoutTimeevery active day. - If a session’s duration spans multiple days, it connects at
logonTimeon thefirstDayand disconnects atlogoutTimeon thelastDay.
Session sequence numbers are reset at the beginning of each trading week.
File-based Configuration
Schedules and connection parameters can be defined in an XML configuration file and referenced in code.
This approach simplifies deployment and configuration management.
The presets can be loaded using the biz.onixs.cme.ilink3.scheduler.SchedulerSettingsLoader class, allowing both schedules and connection settings to be referenced by string identifiers.
Configuration File Reference
The configuration file uses an XML-based format.
The XML schema can be found here.
Connection Management and Multiple Addresses
A biz.onixs.cme.ilink3.handler.Session connects to one endpoint per logon attempt
(host + port).
The scheduler acts as a connection manager through
biz.onixs.cme.ilink3.scheduler.SessionConnection.You can configure one address or an ordered list of addresses. During each scheduler-driven connection cycle, addresses are tried in order until one succeeds.
This keeps endpoint failover and retry logic centralized instead of implementing custom reconnect loops in application code.
CME iLink3 Primary/Backup Notes
For a CME fault-tolerant setup:
- Create two biz.onixs.cme.ilink3.handler.Session instances (designated primary and designated backup) that share the same UUID.
- Set the role on each session viabiz.onixs.cme.ilink3.handler.FaultToleranceIndicator before registering them in the scheduler.
- Register each session with its ownbiz.onixs.cme.ilink3.scheduler.SessionConnection (typically primary MSGW endpoint(s) for
the primary session and backup MSGW endpoint(s) for the backup session).
- Use biz.onixs.cme.ilink3.handler.session.FailoverListener to react to role changes and keep sequence state synchronized across sessions.
- Be aware CME can reject a designated backup logon if the designated primary is not established first
(
DesignatedBackupcondition).
The scheduler automates connection timing, but primary/backup role handover and sequence-state alignment remain application responsibilities.
Quartz Configuration
The session scheduler uses the Quartz Scheduler library internally.
When started, it loads a default Quartz configuration from the embedded resource:
Error during retrieving content skip as ignoreDownloadError activated.
This configuration is bundled inside the scheduler JAR file.
Custom Quartz configurations can be provided using the biz.onixs.cme.ilink3.scheduler.SessionScheduler.setQuartzConfigFile(String) method.
See the full Quartz configuration reference here.
Samples
See Samples :: Scheduler for examples of usage and configuration.
Java CME iLink3 Handler