Working with FIX Session Timers

In this article we show examples of how you can configure one or more FIX timers to perform any kind of action on your FIX session, such as resetting the sequences and connect/disconnect.

Daily and Weekly Timers

CoralFIX comes with two ready-to-use timers that you can use in your FIX clients. See the examples below:

// a timer that will trigger everyday 15:30:00 America/New_York
FixSessionTimer timer = new DailyFixSessionTimer(TimeZone.getTimeZone("America/New_York"), 15, 30, 0);
System.out.println(timer); // => DailyFixSessionTimer-America/New_York-15:30:0

// a timer what will trigger every Sunday at 14:30:00 America/New_York
FixSessionTimer timer = new WeeklyFixSessionTimer(TimeZone.getTimeZone("America/New_York"), Calendar.SUNDAY, 14, 30, 0);
System.out.println(timer); // => WeeklyFixSessionTimer-America/New_York-SUNDAY-14:30:0

Adding Timers to a FIX Client

There are two actions for a timer:

  • Stop: Disconnects and closes the client
  • Start: Resets both inbound and outbound sequences and reconnects the client

NOTE: You can also use the config options “resetSequencesOnStartTimerEvent” and “reconnectOnStartTimerEvent” to fine tune the start action. Both of these options default to true.

To add one or more timers you pass them as config options. For the config option key you can use:

"startSessionTimer" => no label for this start timer
"startSessionTimer-myStartTimer" => "myStartTimer" is the label for this start timer
"stopSessionTimer" => no label for this stop timer
"stopSessionTimer-myStopTimer" => "myStopTimer" is the label for this stop timer

The formats for the weekly and daily timers are:

DailyTimer => D-TZ-HH:MM:SS => "D-America/New_York-13:00:00"
WeeklyTimer => W-DAY-TZ-HH:MM:SS => "W-SATURDAY-America/New_York-15:00:00"

See below some code examples:

// add a start session timer daily at 14:30:00 America/New_York
config.add("startSessionTimer", "D-America/New_York-14:30:00");

// add a stop session timer weekly on Sunday at 16:00:00 America/New_York
config.add("stopSessionTimer", "W-SUNDAY-America/New_York-16:00:00");

// add a second start session timer with label "midweekStart" weekly on Wednesday at 14:00:00 America/New_York
config.add("startSessionTimer-midweekStart", "W-WEDNESDAY-America/New_York-14:00:00");

// add a second stop session timer with lable "midweekStop" weekly on Wednesday at 13:00:00 America/New_York
config.add("stopSessionTimer-midweekStop", "W-WEDNESDAY-America/New_York-13:00:00");

Additional Features

Timers are smart! That means they will inform the FIX client if it is in a down period and prevent a connection to the server until the next start timer triggers. The FixApplicationClient will also detect a missed start timer (i.e. start timer that was supposed to trigger but the client wasn’t running) and reset the sequences appropriately on the next time the client is started.

Handling Multiple Timers

There can be a situation where each timer needs to perform a different action inside the handleTriggered method. For that you can use the FixSessionTimer argument passed in the method to find out which timer has triggered. In order to do that you can compare the timers by reference or by label as the example below demonstrates:

public class MyClient extends FixApplicationClient {

   // (...)

   protected void handleTriggered(FixSessionTimer timer, boolean isCloseTrigger, boolean isMissedStartTrigger) {

      if (timer == timer1) {
            // your specific action here

      } else if (timer == timer2) {
         super.handleTriggered(timer); // reset both sequences

      // OR

      if (timer.getLabel().equals("myTimerLabel1")) {

            // your specific cation here

      } else if (timer.getLabel().equals("myTimerLabel2")) {
         super.handleTriggered(timer); // reset both sequences

Implementing Timers

The DailyFixSessionTimer and the WeeklyFixSessionTimer should be enough for most situations. However, if you want to implement your own timer with a more complicated schedule, you can code your own implementation of the FixSessionTimer interface.


CoralFIX allows you to schedule timers to perform any kind of action you need on your FIX session, such as resetting sequences and connect/disconnect.