Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For each change of session state, FIXEdge creates a new internal FIX message (35=C | 49=fake | 56=fake ) and sends this message into the business layer to notify about the changes.

...

  1. parse tag 147 using JavaScript;
  2. save session state to history. 

Message parsing

In order to get a session state, it is recommended to use the script below. It allows to parse allows parsing tag 147 in the 35=C message which contains the session name and actual session state. 

...

In order to save session state to the database it is required to perform the following steps::

  1. Create a corresponding table to store session statuses;
  2. Create a stored procedure which that allows to write writing data into the table.

Please find an example below. In this case, the PostgreSQL database is used.

...

FIXEdge configuration

 In order to save the session state into the database, BL-Rules should be configured on the FIXEdge side:

  1. Rule The rule for history definition: history name, database parameters,  fields definitions.
  2. Rule The rule for saving to history: get the message 35 = C, get the session status using JavaScript, save to history (database).
BL_Config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
<!DOCTYPE FIXEdge SYSTEM "BusinessLayer.dtd">
-->
<FIXEdge>
 <BusinessLayer>
  <!-- DB Table with Session Status -->
  <History
            Name="SessionStatus"
            StorageType="ODBC"
            TableName="FIXEdge.dbo.SessionStatus"
            ConnectionString="DSN=FIXEdgeDB;UID=user;PWD=password;"
            UseStoredProcForInsert="true"
            StoredProcName="insertSessionStatus"
            >
   <KeyField ColumnName="_SenderCompId">49</KeyField> <!-- SenderCompId -->
   <KeyField ColumnName="_TargetCompId">56</KeyField> <!-- TargetCompId -->
   <KeyField ColumnName="_OrigTime">42</KeyField> <!-- OrigTime -->
   <KeyField ColumnName="_SessionState">147</KeyField> <!-- Session's State -->
  </History>
  <!-- Save Events in 35=C messages notifing about session state to DB -->
  <Rule>
   <Source>
    <FixSession SenderCompID=".*" TargetCompID=".*" />
   </Source>
   <Condition>
    <MatchField Field="35" Value="C"/>
    <MatchField Field="147" Value=".*:.*"/> <!-- Assume sender and target in 147 field is divided by ':'. The rest of the messages are redundant -->
    <Exclusion>
     <MatchMessage Value=".*147=.* AttemptToConnect.*"/>
    </Exclusion>
   </Condition>
   <Action>
    <Script Language="JavaScript" FileName="FIXEdge1/conf/prepareSessionState.js"/>
    <SaveToHistory Name="SessionStatus"/>
   </Action>
  </Rule> 


  <DefaultRule>
   <Action>
    <DoNothing/>
   </Action>
  </DefaultRule>
 </BusinessLayer>
</FIXEdge>
Info

The tag (42) OrigTime is saved as a string. If it is needed to save it as Datetime type it is required to convert it to the specific format via JavaScript.

E.g. from 'YYYYMMDD-hh:mm:ss' to 'YYYYMMDD hh:mm:ss':

setStringField(42, getStringField(42).replace("-", " "));


File history

FIXEdge configuration

 In order to save the session state into the history file, BL-Rules should be configured on the FIXEdge side:

  1. Rule The rule for history definition: history name, history file parameters,  fields definitions.
  2. Rule The rule for saving to history: get message 35 = C, get session status using JavaScript, save to history (file).

...

 As a result, FIXEdge creates a history file with session statuses:

...