Overview
For each changing of session state, FIXEdge creates a new internal FIX message (35=C | 49=fake | 56=fake ) and sends this message into business layer to notify about changes.
The tag 147 in this message is automatically filled by the pattern: [<Category>] <SenderCompID:TargetCompID> <Actual Session state>.
In order to track session state it is required to perform the following steps:
- parse tag 147 using JavaScript;
save session state to history.
Message parsing
In order to get session state, it is recommended to use the script below. It allows to parse tag 147 in the 35=C message which is contain session name and actual session state.
As the result of the script we get three tags: 56 - TargetCompID, 49 - SenderCompID, 147 - State.
prepareSessionState.js |
---|
status = getStringField(147); var regexp = /.*\s+(\w+):(\w+)\s+(.*)/g; match = regexp.exec(status); if (match != null) { target = match[1]; sender = match[2]; state = match[3]; //print("[DEBUG] matched target = " + target + " sender = " + sender + " state = " + state); setStringField(56, target); setStringField(49, sender); setStringField(147, state); } |
ODBS history
Database configuration
In order to save session state to the database is needed to create:
- corresponding table to store session statuses;
stored procedure which allows to write data into the table.
Please find an example below. In this case PostgreSQL database is used.
SessionStatus.sql |
---|
create table session_actions( id serial PRIMARY KEY, _SenderCompId varchar(64) NOT NULL, _TargetCompId varchar(64) NOT NULL, _OrigTime varchar(21) NOT NULL, _SessionState varchar(20) NOT NULL ); CREATE OR REPLACE FUNCTION insertSessionStatus ( _SenderCompId varchar(64), _TargetCompId varchar(64), _OrigTime varchar(21), _SessionState varchar(20) ) RETURNS void AS $$ BEGIN insert into session_actions(SenderCompId, TargetCompId, OrigTime, SessionState) values ( _SenderCompId, _TargetCompId, _OrigTime, _SessionState); END; $$ LANGUAGE plpgsql; |
FIXEdge configuration
In order to save session state into the database BL-Rules should be configured on the FIXEdge side:
BL_Config (4).xml |
---|
<?xml version="1.0" encoding="UTF-8"?> <!-- DB Table with Session Status --> <!-- Save Events in 35=C messages notifing about session state to DB --> <DefaultRule> </BusinessLayer> |
File history