• Programming Guide
  • Api Documentation
  • OnixS CME iLink3 Handler for .NET Core, version 1.4.2
Show / Hide Table of Contents
  • Introduction
  • System Requirements
  • Getting Started
    • Error Reporting
    • Licensing
    • SBE Message
      • Tag-based Messaging
      • Message Fields
      • Repeating Groups
    • iLink 3 Session
      • Universally Unique Identifier
      • Establishing iLink3 Connection
      • Exchanging Messages
      • Message Sequence Numbers
  • Configuring the Handler
    • Configuration File Examples (XML or JSON)
  • Logging
  • Session Storage
    • File-Based Session Storage
    • Memory-based Session Storage
    • Asynchronous File-Based Session Storage
    • Pluggable Session Storage
  • Advanced Programming
    • Thread Safety
    • Session Initialization and Binding
    • Session States
    • Listening to Session Events
    • Handling NotApplied Messages
    • Handling Business Reject Messages
    • Automated Downloading of GTC and GTD Orders
    • Reconnection
    • Fault Tolerance
    • Understanding Send Latency
    • Strongly Typed Messages
  • Best Practices
    • Low Latency Best Practices
  • Glossary
  • Support

Fault Tolerance

Backup Session

The backup session must use the same Universally Unique Identifier (UUID) as the primary session.

Before establishing the connection with the backup Market Segment Gateway, set FaultToleranceIndicator to Backup.

Note

A backup session must be ready to activate in the same data state as the previous primary session being replaced. For example, inbound and outbound sequence numbers for a UUID must be maintained in a consistent state during failover between both sessions.

See Also

The Fault Tolerance CME article.

Primary Session Failure

If the exchange does not receive a message from the primary session within two times the KeepAliveInterval value, then the exchange designates the primary session as failed and initiates the failover:

  • Both the primary and backup sessions will be disconnected from the exchange, the backup session will receive the Terminate message.
  • The backup session will be expected to connect to the primary Market Segment Gateway.

Primary Market Segment Gateway Failure

If the primary Market Segment Gateway Gateway fails, then the exchange initiates failover by electing the backup Market Segment Gateway to assume the primary role.

The backup session connected to this newly chosen Market Segment Gateway must act as the primary one. It is notified about the failover via the Failover event.

After the failover the FaultToleranceIndicator property returns Primary.

Example


void OnFailover(object sender, FailoverEventArgs args)
{
    Console.WriteLine($"Primary Market Segment Gateway Failure, faultToleranceIndicator={args.FaultToleranceIndicator}.");

    ((Session)sender).InSeqNum = lastKnownPrimarySessionInSeqNum;
    ((Session)sender).OutSeqNum = lastKnownPrimarySessionOutSeqNum;
}

void OnInboundSessionMessage(object sender, InboundMessageEventArgs args)
{
    const int TerminateTemplateId = 507;
    if (args.Message.TemplateID == TerminateTemplateId)
    {
        const int ErrorCodesTag = 39012;
        const int DisconnectFromPrimary = 26;
        if (args.Message.GetUnsignedShort(ErrorCodesTag) == DisconnectFromPrimary)
        {
            Console.WriteLine("Primary Session Failure.");
        }

    }
}

using (Session primary = new Session(settings, marketSegmentId))
{
    primary.Failover += OnFailover;
    primary.InboundSessionMessage += OnInboundSessionMessage;

    primary.Connect(PrimaryGateway, GatewayPort);

    using (Session backup = new Session(settings, marketSegmentId, uuid: primary.SessionId.Uuid, customKey: "BackupSession"))
    {
        backup.Failover += OnFailover;
        backup.InboundSessionMessage += OnInboundSessionMessage;

        backup.FaultToleranceIndicator = FaultToleranceIndicator.Backup;

        backup.Connect(BackupGateway, GatewayPort);
    }
}
In This Article
Back to top Copyright © Onix Solutions.
Generated by DocFX