## Apache Synapse

## Sample 262: Content Based Routing of FIX Messages

<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="CBR_SEQ"> <in> <switch source="//message/body/field[@id='55']"> <case regex="GOOG"> <send> <endpoint> <address uri="fix://localhost:19876?BeginString=FIX.4.0&SenderCompID=SYNAPSE&TargetCompID=EXEC"/> </endpoint> </send> </case> <case regex="MSFT"> <send> <endpoint> <address uri="fix://localhost:19877?BeginString=FIX.4.1&SenderCompID=SYNAPSE&TargetCompID=EXEC"/> </endpoint> </send> </case> <default/> </switch> </in> <out> <send/> </out> </sequence> <proxy name="FIXProxy" transports="fix"> <target inSequence="CBR_SEQ"/> <parameter name="transport.fix.AcceptorConfigURL"> file:repository/conf/sample/resources/fix/fix-synapse.cfg </parameter> <parameter name="transport.fix.AcceptorMessageStore"> file </parameter> <parameter name="transport.fix.InitiatorConfigURL"> file:repository/conf/sample/resources/fix/synapse-sender.cfg </parameter> <parameter name="transport.fix.InitiatorMessageStore"> file </parameter> </proxy> </definitions>

### Objective

Show case the ability of Synapse to route FIX messages based on the content they carry.

### Pre-requisites

- You need a Quickfix/J installation to try out FIX samples. Please download and extract a Quickfix/J distribution into your local machine.
- Configure the Executor sample FIX application (shipped with Quickfix/J) to receive messages from Synapse and start it (refer FIX setup guide for more details). In previous samples we only had a FIX 4.0 session configured for Executor. For this sample we should also configure a FIX 4.1 session for Executor. Therefore before starting it add the following entries to the configuration file of Executor. (Do not remove or change the FIX 4.0 configuration already available in this file)
  [session] BeginString=FIX.4.1 SocketAcceptPort=19877
- Enable the FIX transport listener and sender for Synapse (refer FIX setup guide for details).
- Start Synapse using the configuration numbered 262 (repository/conf/sample/synapse_sample_262.xml)
  Unix/Linux: sh synapse.sh -sample 262
  Windows: synapse.bat -sample 262
  If the Executor was configured properly Synapse should establish 2 sessions with Executor upon startup (FIX 4.0 session and FIX 4.1 session)
- Configure Banzai sample FIX application (shipped with Quickfix/J) to send messages to Synapse and start it (refer FIX setup guide for more details). You should also add the following entry to the Banzai configuration file before starting it (replace $SYNAPSE_HOME with the actual path to Synapse home).
  DataDictionary=$SYNAPSE_HOME/repository/conf/sample/resources/fix/FIX40-synapse.xml
  If Banzai was properly configured, it should establish a FIX 4.0 session with Synapse upon startup. You should see some session logon messages on Synapse console and Banzai console.

### Executing the Client

Send some order requests from Banzai to Synapse containing the synbols 'GOOG' and 'MSFT'. Synapse will forward the messages with the symbol 'GOOG' to the FIX 4.0 session. Messages containing the symbol 'MSFT' will be sent to the FIX 4.1 session. Any other messages will be simply dropped by the service bus since the default case of the switch mediator has been kept empty.

Back to Catalog