Sunday, August 3, 2014

FIX(Financial Information eXchange) protocol supporting Transport in UltraESB


UltraESB supports FIX Message transfer and is available with V2.2.0. This is implemented with the QuickFixJ open source FIX implementation.

As shown in the in the below diagram, instead of directly talking to the FIX service , UltraESB acts as the proxy for all the fix messages going to the back-end fix endpoint.


Sample Configuration

The configuration for this use case consists of a proxy service identified as "fix-proxy", exposed on the FIX transport and forwards the incoming message into the target back-end service configured using the in destination of the proxy service.

FIX Transport Listener configuration

Fix Transport listener work as the fix message acceptor in UltraESB.  Configuration properties you define in the transport listener <property> tags are used as [Default] properties for creating socket acceptor in QuickFix/j. All the messages receive through this transport listener will actually accept fix messages with socket acceptor created with using default properties same to properties given in transport-listener. There are essential properties need to set in order to create a QuickFIX/j socket acceptor, and other properties can be configured in the map named 'otherSettings'.
If you want to create several sessions through same acceptor those [Session] properties are configured within the proxy service under transport properties.
eg: If you have 2 sessions, one with FIX version 4.2 and other with FIX version 4.3, in proxy service define properties as following.
Property name suffixes are only to indicate the settings belong to a same session.
Property name prefix must be 'ultra.fix.session.' + property_name. To find allowed properties, refer 'FIX Transport'

FIX Transport Sender configuration

Fix Transport sender act as the initiator in UltraESB which initiate a session with a external fix endpoint and send fix messages it received. Configuration properties you define in the transport sender <property> tags are used as [Default] properties for creating socket initiator in QuickFix/j. All the messages send via this transport sender will actually send fix messages with socket initiator created with using default properties same to properties given in transport-sender. There are essential properties need to set in order to create a QuickFIX/j socket initiator, and other properties can be configured in the map named 'otherSettings'.

FIX Endpoint

This defines the final destination that the fix-message should receive.
There are  three mandatory parameters (BeginString, SenderCompID and TargetCompID) need to create a new session. These three parameters must be given in the endpoint address in the format - fix://<host>:<port>?BeginString=<>&amp;SenderCompID=<>&amp;TargetCompID=< > . Other optional properties can be configured as <u:property.. in endpoint with property name , ultra.fix.endpoint.session.+ property_id.

property_id

property_id should be given in the same syntax defined in QuickFIX/J configuration. Refer QuickFIX/J configuration to find the exact IDs.

New initiator is created for each endpoint you define with using endpoint properties you define as [Session] settings and transport-sender properties as [Default] settings.

Make sure you don't define values for same property within the transport sender and , endpoint.

Setting Log factory

In QuickFIX/J logging can be done file base(fileLogFactory) or by saving to database(jdbcLogFactory). In this sample transport-listener and transport-sender configured to use file base logs (acc-fileLogFactory and ini-fileLogFactory). Following is how to configure fileLogfactory beans. Give the location of where to save the logs in fileLogPath property, here it is configured to '/tmp/fixTest'.


To persist loggin information to a database, define a 'dataSource' and 'fix-jdbcLogFactory' by setting required database information and give reference to 'logFactory' property in FIX transport listener and FIX transport sender. Sample configuration is included in sample-550 which you can un-comment and use.

Setting Message Factory

The message store is used by a fix session to store and retrieve messages for resend purposes. QhickFIX/J allow to store messages in file base(FileMessageStoreFactory) or in a database(JDBCMessageStoreFactory). In this sample transport-listener and transport-sender configured to use file base messageStores (acc-fileMessageStore and ini-fileMessageStore). Following is how to configure JDBCMessageStoreFactory beans. Give the location of where to save the messages in 'messageStoreFactory' property, here it is configured to '/tmp/fixTest'.



To persist messages in a database, define a 'dataSource' and 'fix-jdbcMessageStore' by setting required database information and giving reference to 'messageStoreFactory' property in FIX transport listener and FIX transport sender. Sample configuration is included in sample-550 which you can un-comment and use.

Sending sample FIX message through UltraESB

To issue a fix message you may refer the unit test FIXMessageExchangeTest.java.
Following is how to send a sample fix message through a external client, mediate message with UltraESB  and forwarding to the destination fix endpont. To send and receive a sample fix message you can use samples provided by QuickFIX/J, BANZAI and EXECUTOR
  1. Since UltraESB do not ship required jars to FIX transport, you need to add following jars in to 'lib/custom'
  •  quickfixj-all-1.5.3.jar
  •   mina-core-1.1.7.jar 
          
     2. Start the UltraESB sample configuration 550 via the ToolBox or on the command line as follows.

$ cd /opt/ultraesb-2.2.0/bin
$ ./ultraesb.sh -sample 550
Proper starting of FIX transport listener and FIX transport sender will log as follow. 

2014-04-09 11:45:05,348 [-] [main] [system] [000000I]  INFO FIXTransportSender Started FIX Transport sender : fix-sender...
2014-04-09 11:45:05,358 [-] [main] [system] [000000I]  INFO SimpleQueueWorkManager Started Work Manager : default
2014-04-09 11:45:05,359 [-] [main] [system] [000000I]  INFO ServerManager Initializing transport listeners
2014-04-09 11:45:05,364 [-] [main] [system] [000000I]  INFO ServerManager Starting Proxy Services, Endpoints and Sequences
2014-04-09 11:45:05,371 [-] [main] [system] [000000I]  INFO Address Started Address : address of endpoint : fix-endpoint
2014-04-09 11:45:05,371 [-] [main] [system] [000000I]  INFO fix-endpoint Endpoint : fix-endpoint started
2014-04-09 11:45:05,376 [-] [main] [system] [000000I]  INFO Address Started Address : address of endpoint : mediation.response
2014-04-09 11:45:05,376 [-] [main] [system] [000000I]  INFO Endpoint Endpoint : mediation.response started
2014-04-09 11:45:07,391 [-] [main] [system] [000000I]  INFO fix-proxy-inSequence Sequence : fix-proxy-inSequence started
2014-04-09 11:45:07,394 [-] [main] [system] [000000I]  INFO Address Started Address : address of endpoint : fix-proxy-outDestination
2014-04-09 11:45:07,394 [-] [main] [system] [000000I]  INFO fix-proxy-outDestination Endpoint : fix-proxy-outDestination started
2014-04-09 11:45:07,396 [-] [main] [system] [000000I]  INFO fix-proxy Proxy service : fix-proxy started
2014-04-09 11:45:07,396 [-] [main] [system] [000000I]  INFO ServerManager UltraESB root deployment unit started successfully
2014-04-09 11:45:07,396 [-] [main] [system] [000000I]  INFO ServerManager Starting transport listeners
2014-04-09 11:45:11,142 [-] [main] [system] [000000I]  INFO FIXSessionFactory Created new socket acceptor for transport listener: fix-lsnr
2014-04-09 11:45:11,234 [-] [main] [system] [000000I]  INFO FIXTransportListener Socket acceptor for fix transport listener: fix-lsnr started
2014-04-09 11:45:11,234 [-] [main] [system] [000000I]  INFO FIXTransportListener Started FIX Listener : fix-lsnr

  3. Download QuickFIX/J and run the sample they have provided(Banzai-Executor) with modifying configuration as bellow.Here we are sending a message from Banzai(initiator to port 12000) to UltraESB(working as an acceptor listening in port 12000) over session FIX.4.2. After receiving the message from Banzai UltraESB(working as an initiator) will forward the message to Executor(acceptor listening in port 9879)


Initiator configuration for Banzai (banzai.cfg)


Acceptor configuration for Executor(executor.cfg)


Following is the UI provided by QuickFIX/J sample, you can send a message with this UI over session FIX.4.2:BANZAI->UESB.


 Banzai console output

// initiating session and sending order message
<20140409-06:24:38, FIX.4.2:BANZAI->UESB, event> (Session FIX.4.2:BANZAI->UESB schedule is daily, 00:00:00-UTC - 23:00:00-UTC)
<20140409-06:24:38, FIX.4.2:BANZAI->UESB, event> (Session state is not current; resetting FIX.4.2:BANZAI->UESB)
<20140409-06:24:38, FIX.4.2:BANZAI->UESB, event> (Created session: FIX.4.2:BANZAI->UESB)
<20140409-06:24:39, FIX.4.2:BANZAI->UESB, outgoing> (8=FIX.4.29=6535=A34=149=BANZAI52=20140409-06:24:39.48856=UESB98=0108=3010=243)
<20140409-06:24:39, FIX.4.2:BANZAI->UESB, event> (Initiated logon request)
<20140409-06:24:39, FIX.4.2:BANZAI->UESB, incoming> (8=FIX.4.29=6535=A34=149=UESB52=20140409-06:24:39.56456=BANZAI98=0108=3010=238)
<20140409-06:24:39, FIX.4.2:BANZAI->UESB, event> (Received logon)
<20140409-06:25:09, FIX.4.2:BANZAI->UESB, outgoing> (8=FIX.4.29=12935=D34=249=BANZAI52=20140409-06:25:09.24456=UESB11=139702470918721=138=1040=154=155=dell59=060=20140409-06:25:09.24210=206)
<20140409-06:25:10, FIX.4.2:BANZAI->UESB, incoming> (8=FIX.4.29=5335=034=249=UESB52=20140409-06:25:10.15656=BANZAI10=181)

// receiving acknowledgement from Executor via UltraESB
<20140409-06:25:10, FIX.4.2:BANZAI->UESB, incoming> (8=FIX.4.29=12435=834=349=UESB52=20140409-06:25:10.68756=BANZAI6=011=139702470918714=017=120=037=139=054=155=dell150=2151=010=061)
<20140409-06:25:10, FIX.4.2:BANZAI->UESB, incoming> (8=FIX.4.29=14835=834=449=UESB52=20140409-06:25:10.68856=BANZAI6=12.311=139702470918714=1017=220=031=12.332=1037=238=1039=254=155=dell150=2151=010=130)
 
 UltraESB console output
 
// receiving message from Banzai and sending to Executor
2014-04-09 11:54:39,537 [-] [SocketAcceptorIoProcessor-0.0] [system] [000000I]  INFO FIXTransportListener FIX session with SessionID: FIX.4.2:UESB->BANZAI created for fix listener: fix-lsnr
2014-04-09 11:54:39,578 [-] [QF/J Session dispatcher: FIX.4.2:UESB->BANZAI] [system] [000000I]  INFO FIXTransportListener FIX session with SessionID: FIX.4.2:UESB->BANZAI logged in via fix listener: fix-lsnr
2014-04-09 11:55:09,539 [-] [QF/J Session dispatcher: FIX.4.2:UESB->BANZAI] [system] [000000I]  INFO FIXSessionFactory Started initiator for endpoint address: FIX.4.2:UESB->EXEC with session ID: fix://localhost:9879?BeginString=FIX.4.2&SenderCompID=UESB&TargetCompID=EXEC 
2014-04-09 11:55:09,540 [-] [QF/J Session dispatcher: FIX.4.2:UESB->BANZAI] [system] [000000I]  INFO FIXTransportSender Fix message sent to target over session: FIX.4.2:UESB->EXEC

// receiving acknowledgement from Executor and sending back to Banzai
2014-04-09 11:55:10,687 [-] [QF/J Session dispatcher: FIX.4.2:UESB->EXEC] [system] [000000I]  INFO FIXTransportSender Acknowledgement message received from:UESB sent to message sender: BANZAI
2014-04-09 11:55:10,689 [-] [QF/J Session dispatcher: FIX.4.2:UESB->EXEC] [system] [000000I]  INFO FIXTransportSender Acknowledgement message received from:UESB sent to message sender: BANZAI 

 
Executor console output

// receiving order message from UESB 
<20140409-07:08:34, FIX.4.2:EXEC->UESB, incoming> (8=FIX.4.29=15435=D34=143=Y49=UESB52=20140409-07:08:34.55056=EXEC122=20140409-07:08:3311=139702731319321=138=1040=154=155=dell59=060=20140409-07:08:33.21610=109)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, incoming> (8=FIX.4.29=8935=434=243=Y49=UESB52=20140409-07:08:34.55256=EXEC122=20140409-07:08:3436=3123=Y10=125)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, event> (ResendRequest for messages FROM 1 TO 1 has been satisfied.)

// sending acknowledgement to UESB 
<20140409-07:08:34, FIX.4.2:EXEC->UESB, outgoing> (8=FIX.4.29=12235=834=349=EXEC52=20140409-07:08:34.59056=UESB6=011=139702731319314=017=120=037=139=054=155=dell150=2151=010=163)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, outgoing> (8=FIX.4.29=14635=834=449=EXEC52=20140409-07:08:34.59256=UESB6=12.311=139702731319314=1017=220=031=12.332=1037=238=1039=254=155=dell150=2151=010=233)<20140409-07:08:34, FIX.4.2:EXEC->UESB, incoming> (8=FIX.4.29=15435=D34=143=Y49=UESB52=20140409-07:08:34.55056=EXEC122=20140409-07:08:3311=139702731319321=138=1040=154=155=dell59=060=20140409-07:08:33.21610=109)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, incoming> (8=FIX.4.29=8935=434=243=Y49=UESB52=20140409-07:08:34.55256=EXEC122=20140409-07:08:3436=3123=Y10=125)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, event> (ResendRequest for messages FROM 1 TO 1 has been satisfied.)

<20140409-07:08:34, FIX.4.2:EXEC->UESB, outgoing> (8=FIX.4.29=12235=834=349=EXEC52=20140409-07:08:34.59056=UESB6=011=139702731319314=017=120=037=139=054=155=dell150=2151=010=163)
<20140409-07:08:34, FIX.4.2:EXEC->UESB, outgoing> (8=FIX.4.29=14635=834=449=EXEC52=20140409-07:08:34.59256=UESB6=12.311=139702731319314=1017=220=031=12.332=1037=238=1039=254=155=dell150=2151=010=233)


No comments:

Post a Comment