Page tree
Skip to end of metadata
Go to start of metadata

FIX Antenna Java provides API, which helps to detect problems with consumer communication. Sometimes it may be useful to apply different strategies in application to handle consumer with slow communication abilities.

To enable this functionality you have to set few options for FIX session: 

SessionParameters details = new SessionParameters();
...
//Enable slow consumer detection logic
details.getConfiguration().setProperty(Configuration.SLOW_CONSUMER_DETECTION_ENABLED, "true");

// Define maximum timeframe for sending FIX message to cient in milliseconds
details.getConfiguration().setProperty(Configuration.SLOW_CONSUMER_WRITE_DELAY_THRESHOLD, "50");


Also, it needs to register a handler of FIXSessionSlowConsumerListener type for processing notification about detected sending problems. FIXSessionSlowConsumerListener interface has a single method with 3 parameters: reason, expectedValue, currentValue.

FIX Antenna notifies about two suspicious cases during messages sending:

  • TRANSPORT_WRITE_DELAY - message sending (writing to outgoing transport) time exceed SLOW_CONSUMER_WRITE_DELAY_THRESHOLD timeout. In this case expectedValue contains SLOW_CONSUMER_WRITE_DELAY_THRESHOLD timeout and currentValue shows the real message sending time. Of course, currentValue > expectedValue.
  • TRANSPORT_WRITE_NOT_COMPLETE -  FIX Antenna wasn't able to write a whole message at one time. It means that consumer reads slowly or it still not processed the previous message and TCP buffer is full. In this case expectedValue contains the current message size and currentValue - the size, which transport was able to push (expectedValue > currentValue). 

session.setSlowConsumerListener((reason, expectedValue, currentValue) -> {
    switch (reason) {
        case TRANSPORT_WRITE_DELAY:
            System.out.println("Writes a message too long - " + currentValue);
            break;
        case TRANSPORT_WRITE_NOT_COMPLETE:
            System.out.println("Consumer can't get whole message package - " + currentValue);
            break;
    }
});
  • No labels