Session-level Dictionary
The dictionary examples described above refer to engine-level dictionaries. The dictionary changes will affect each session that uses the modified FIX protocol version. Sometimes there is a need to use different FIX dictionaries in FIX sessions within the same Engine instance. For this use case, the Engine provides per-session dictionaries.
Identifying Session-level Dictionary in Dictionary Description File
To reduce the scope of a dictionary definition from engine-level to session-level, add to the dictionary definition the id
attribute:
<?xml version="1.0" encoding="utf-8"?>
<Dialect xmlns="https://ref.onixs.biz/fix/dialects"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ref.ref.onixs.biz/fix/dialects https://ref.onixs.biz/fix/dialects/dialects-2.18.xsd">
<FIX version="4.0" id="CustomFixDictionary">
<!-- Dictionary description here. -->
</FIX>
</Dialect>
Note
When the dictionary description has a non-empty id
attribute, the Engine will not use it for all sessions and messages. Instead, such a dictionary can be used only by sessions and messages that explicitly reference it.
Referencing Dictionary
In the source code, the IMessageInfoDictionary instance must be found using the Find(string) method. It accepts only one parameter that identifies the dictionary you would like to
apply for the session. The value of this parameter must be the same as the value of the id
attribute in the XML description. Once the IMessageInfoDictionary instance is found, the FIX session can be initialized. The
Session initialization is performed in the usual way with only one difference: instead of supplying the version of the FIX protocol, the IMessageInfoDictionary instance must be passed.
After that, the created session will operate using the specified session-level dictionary.
For example:
var dictionary = MessageInfoDictionary.Find("CustomFixDictionary");
var session = new Session("Sender", "Target", dictionary);
Creating Messages
To create messages of the specific FIX Dictionary, supply the IMessageInfoDictionary instance during the Message construction.
For example:
var dictionary = MessageInfoDictionary.Find("CustomFixDictionary");
var message = new Message(OnixS.Fix.Fix42.MsgType.Order_Single, dictionary);