image/svg+xml
  • OnixS .NET FIX Engine
  • Programming Guide
  • Api Documentation
  • Version 1.16.0
    • Programming Guide
    • Messaging
    • Flat Messages
Show / Hide Table of Contents
  • Introduction
  • System Requirements
  • Project Dependency Management
  • Getting Started
  • Error Reporting
  • Licensing
  • Engine Initialization and Shutdown
  • Selecting FIX Version
  • FIX Message
    • Manipulating Message Fields
  • FIX Session
    • Establishing FIX Connection
    • Exchanging Messages
    • Message Sequence Numbers
  • Configuring the Engine
    • Loading Engine Settings From Configuration Files
    • Multiple Listen Ports
  • Logging Services
    • Selecting Session Storage
    • Customizing Message Logging
  • Threading Model
  • Thread Safety
  • Repeating Groups
  • Sessions
    • Session States
    • Session Events
    • Accepting FIX Session Without a Prior Creation of Session Object
    • Custom Logon Message
    • Logon Authentication
    • Establishing FIX Connection via Proxy
    • Resetting Message Sequence Numbers
    • Resetting Message Sequence Numbers via ResetSeqNumFlag Field
    • Resending Messages
    • Memory-based Session Storage
    • File-based Session Storage
    • Async File-based Session Storage
    • Pluggable Session Storage
    • Scheduling Session for Automatic Connection
      • Session Schedule
      • Session Connection Settings
      • XML-based Schedules and Connection Settings
    • Failover
    • Message Sending Latency
    • Message Receiving Latency
    • Message Throttling
  • Messaging
    • Manipulating Real Numbers
    • Message Validation
    • Serialized FIX Messages
    • Typed FIX Messages
    • Flat Messages
      • Flat Group Reader
    • Using LINQ
  • FIX Dictionary
    • XML-based Dictionary Description
    • Session-level Dictionary
    • Dictionary Exploration
    • Using QuickFIX Data Dictionary
  • Engine Events
  • TLS/SSL Encryption
    • Using TLS/SSL Encryption
    • Supported Certificates
    • Session-level TLS/SSL Settings
    • Verification of Client SSL Certificates
    • Custom verification of SSL Certificates
    • TLS/SSL Troubleshooting
  • FAST Coding
    • Encoding And Decoding Data Using FAST
    • FAST Template
    • Generating FIX Dictionaries For FAST Coding
    • FAST Exceptions
  • FIXML Converter
  • Reducing Garbage Collection Overhead
  • Best Practices
    • Low Latency Best Practices
    • High Throughput Best Practices
  • Migration Guide
  • Frequently Asked Questions
  • Glossary
  • External Resources
  • Samples
  • Support

Flat Message

Sometimes it is more convenient to work with FIX messages just as sequences of tag=value pairs. For example, an application needs to receive a message, access a few fields, and use the value of these fields to route the message to one of the counterparties (so-called "FIX to FIX routing"). In this scenario, it could be impractical to maintain the FIX Dictionary - especially if messages are received from venues that use different FIX Dictionaries.

To support this scenario, the Engine exposes the FlatMessage class.

Constructing Flat Message

To create a new FlatMessage object, use one of the FlatMessage constructors.

For example:

var message = new FlatMessage(ProtocolVersion.Fix44);

Adding Field

To add a field, use the Add(int, string) method. This method adds the given tag/value pair at the end of the message instance.

For example:

message.Add(OnixS.Fix.Fix44.Tag.ClOrdID, "ClOrdID value");

Accessing Field Value

The flat message field value can be accessed using either the field index or the tag number:

  • Get(int)
  • GetByIndex(int)
Note

When the field is accessed by the tag number, the linear search is performed until the tag is found. The Get(int, int) method has the hintFieldIndex argument to set the search's starting point.

For example:

var clientOrderIdByTag = message.Get(OnixS.Fix.Fix44.Tag.ClOrdID);

var clientOrderIdByTagAndHint = message.Get(OnixS.Fix.Fix44.Tag.ClOrdID, 3);

var clientOrderIdByIndex = message.GetByIndex(5);

Accessing Repeating Fields

See Flat Group Reader.

Removing Field

To remove a field, use the Remove(int) and RemoveLastField() methods.

Enumerating Fields

The FlatMessage class supports the IEnumerable interface, so you can use a FlatMessage instance in the foreach operator to enumerate message fields.

For example:

foreach (Field field in message)
{
    System.Console.WriteLine($"{field.Tag}={field.Value}");
}

Receiving Flat Messages

To receive Flat Messages, set Session's MessageMode property to FlatMessage. In this mode, MessageEventArgs.FlatMessage will contain the reference to the received FlatMessage instance.

For example:

using var initiator = new Session(TargetCompID, SenderCompID, dictionary)
{
    MessageMode = MessageMode.FlatMessage
};

Sending Flat Messages

To send Flat Messages, use the Session.Send(FlatMessage) method method.

FlatMessage versus Message

Class Advantages Disadvantages
Message Supports validation. Fields order is defined by the FIX Dictionary.
Tag-based field access takes constant time. Repeating group fields are lost without the complete FIX Dictionary.
The message type and FIX protocol version cannot be changed.
FlatMessage Repeating group fields are always preserved and can be accessed without the corresponding FIX Dictionary. Tag-based field access takes linear time.
Keeps the field order. Does not support validation.
Any field can be changed.

See Also

  • The FlatMessage sample from the FIX Engine distribution package
  • Flat Group Reader
In this article
  • Constructing Flat Message
  • Adding Field
  • Accessing Field Value
    • Accessing Repeating Fields
  • Removing Field
  • Enumerating Fields
  • Receiving Flat Messages
  • Sending Flat Messages
  • FlatMessage versus Message
  • See Also
Back to top Copyright © Onix Solutions.
Generated by DocFX