FIXEdge routes messages (e.g. orders, cancels) from source systems to destination systems and it is a common case that a destination system accepts messages at the time interval when session is established. But in certain buisness configurations destination system may work as a broker that owns gateway to exchanges, that are ultimate destinations for messages. Ultimate destination may be closed (work on schedule base) while a broker is running. In such cases messages will be rejected by broker. Thus there is a need to store them in a queue and release at a specific time, according to an exchange schedule.
To meet these needs Managed Queue solution provides a way:
- To store messages in the queue during off hours (market is closed)
- To release messages stored in the queue at the time market is open
- To pass through messages during “market is open” hours
- To define multiple queues for different order types
- To distribute incoming orders among the queues relating on order type - to route only messages that can be accepted by certain destination system.
- To apply smart logic for orders stored in the queue (cancel and cancel/replace)
Manage Queue feature description
Logically FIXEdge server is a router that routes messages from a source system to a destination system. The following diagram demonstrates data flow for the case managed queue is used. Messages from a source system are parsed and put to business layer. BL rule is executed and messages that fit the rule are moved to a certain virtual session. Each virtual session is actually a queue. If virtual session is open (connected to a target session) the message is moved to target session immediately. If virtual session is closed (disconnected from a target session) then the message is stored in the queue. The smart logic is applied. The virtual session connects to a target session or disconnects from a target session according to a schedule configured for a virtual session. Target session may also have a schedule. If target session is not established then messages stay in the queue and are released when target session is established.
All messages are persistently stored in SQLite database.
SQLite database schema
SQLite database is used to store queued messages. Default DB name is fe.db. Messages of all queues, sent to all sessions, are stored within single table – “QueueStorage”. Messages that are delivered or removed are marked in corresponding columns.
Factual removal of messages from table can be done manually or by a script using SQLite utilities.
Table “QueueStorage” is described below:
Table Column Name
Unique identifier of a message in the table
Manager Queue Name (the same as virtual session name)
Message Type - taken from tag 35 of a queued message
Source System identity (e.g. SAP) – taken from tag 49 of a queued message
Client order ID - taken from tag 11 of a queued message
Raw FIX message
Time when incoming message was stored in the queue
0 – message was not released (must stay in the queue)
1 – message was released (is sent to a target session)
Time when message was released
0 - message was not removed from a queue by Order Cancel
1 - message was removed from a queue by Order Cancel
Time when message was removed by Order Cancel
Queue releasing process
Queued messages are released when virtual session is connected to a target session and target session is established. Messages are released according to FIFO (First In First Out) logic. If some non-queued messages from the source system are passed to a target session simultaneously with queue release first go the queued messages and then other messages according to FIFO principle.
To use managed queue functionality user must configure BL rule in BL_Config.xml and managed queue and session properties in FIXEdge.properties files.
From the routing perspective BL rule for routing to a virtual session is similar to ordinary BL routing configuration.
The example of BL rule for routing from RestAcceptorClient_Queueing source to MQDEST-XMIC-PreOpen virtual session:
Configuring managed queue
Manages queue properties description:
Type of storage where incoming messages are stored.
File name of a storage
Managed Queue properties example:
Configuring virtual session
Message is routed from source connection to virtual session.
Virtual session properties description:
Name of a virtual session
Destination FIX session for routing a message from virtual session or any other source.
Schedule name for virtual session schedule
Virtual session schedule properties description:
Time when messages stored in the queue are released
Time when session stops sending messages to a target session and starts to store messages in the queue.
Virtual session properties example (source= RestAcceptorClient_Queueing, virtual session= MQDEST-XMIC-PreOpen):
Virtual session schedule properties example:
When ConnectTime trigger is on a message is routed to the target session MQTARGET.
Configuring target session
Target session is configured as ordinary FIX session.
Target session properties example:
Target session schedule example:
Order flow scenarios
Order is queued in trade-off hours, released when market is open
Order goes through without queueing
Cancel eliminates order in the queue
Cancel is queued (no corresponding order in the queue)
Cancel/replace is received, Cancel Reject generated, Order stays in the queue
Smart logic features
Smart Logic is a handler, that can play specialized logic for incoming messages, like canceling orders, sending notifications and so on.
Current implementation includes:
- Matching incoming Cancel with queued Order, deleting both and sending confirmation to BL.
- Cancel/Replace queued Order – send Cancel Reject message, order stays in the queue
For details see order flow scenarios.
Logic in handler is hardcoded, but handler itself can be replaced via FIXEdge plugin system. Smart logic can be turned on/off for all sessions simultaneously.
Turn on smart logic plug-in
(currently for order cancel and cancel/replace)
<ServiceName> is given by user
To turn off plug-in remove or comment this property string