<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<document>
    <properties>
        <title>Apache Synapse - Sample 262</title>
    </properties>
    <body>
        <section name="Sample 262: Content Based Routing of FIX Messages">
            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;

    &lt;sequence name="CBR_SEQ"&gt;
        &lt;in&gt;
            &lt;switch source="//message/body/field[@id='55']"&gt;
                &lt;case regex="GOOG"&gt;
                    &lt;send&gt;
                        &lt;endpoint&gt;
                            &lt;address
                                    uri="fix://localhost:19876?BeginString=FIX.4.0&amp;SenderCompID=SYNAPSE&amp;TargetCompID=EXEC"/&gt;
                        &lt;/endpoint&gt;
                    &lt;/send&gt;
                &lt;/case&gt;
                &lt;case regex="MSFT"&gt;
                    &lt;send&gt;
                        &lt;endpoint&gt;
                            &lt;address
                                    uri="fix://localhost:19877?BeginString=FIX.4.1&amp;SenderCompID=SYNAPSE&amp;TargetCompID=EXEC"/&gt;
                        &lt;/endpoint&gt;
                    &lt;/send&gt;
                &lt;/case&gt;
                &lt;default/&gt;
            &lt;/switch&gt;
        &lt;/in&gt;
        &lt;out&gt;
            &lt;send/&gt;
        &lt;/out&gt;
    &lt;/sequence&gt;

    &lt;proxy name="FIXProxy" transports="fix"&gt;
        &lt;target inSequence="CBR_SEQ"/&gt;
        &lt;parameter name="transport.fix.AcceptorConfigURL"&gt;
            file:repository/conf/sample/resources/fix/fix-synapse.cfg
        &lt;/parameter&gt;
        &lt;parameter name="transport.fix.AcceptorMessageStore"&gt;
            file
        &lt;/parameter&gt;
        &lt;parameter name="transport.fix.InitiatorConfigURL"&gt;
            file:repository/conf/sample/resources/fix/synapse-sender.cfg
        &lt;/parameter&gt;
        &lt;parameter name="transport.fix.InitiatorMessageStore"&gt;
            file
        &lt;/parameter&gt;
    &lt;/proxy&gt;

&lt;/definitions&gt;</div>
            <subsection name="Objective">
                <p>
                    Show case the ability of Synapse to route FIX messages based on the content they
                    carry.
                </p>
            </subsection>
            <subsection name="Pre-requisites">
                <p>
                    <ul>
                        <li>
                            You need a <a href="http://www.quickfixj.org">Quickfix/J</a> installation
                            to try out FIX samples. Please download and extract a Quickfix/J distribution
                            into your local machine.
                        </li>
                        <li>
                            Configure the Executor sample FIX application (shipped with Quickfix/J)
                            to receive messages from Synapse and start it (refer <a href="setup/fix.html#exec">FIX setup guide</a>
                            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)
                            <div class="consoleOutput">[session]
BeginString=FIX.4.1
SocketAcceptPort=19877</div>
                        </li>
                        <li>
                            Enable the FIX transport listener and sender for Synapse (refer
                            <a href="setup/fix.html#synapse">FIX setup guide</a> for details).
                        </li>
                        <li>
                            Start Synapse using the configuration numbered 262 (repository/conf/sample/synapse_sample_262.xml)
                            <div class="command">
                                Unix/Linux: sh synapse.sh -sample 262<br/>
                                Windows: synapse.bat -sample 262
                            </div>
                            If the Executor was configured properly Synapse should establish 2 sessions
                            with Executor upon startup (FIX 4.0 session and FIX 4.1 session)
                        </li>
                        <li>
                            Configure Banzai sample FIX application (shipped with Quickfix/J) to send
                            messages to Synapse and start it (refer <a href="setup/fix.html#banzai">FIX setup guide</a>
                            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).
                            <div class="consoleOutput">DataDictionary=$SYNAPSE_HOME/repository/conf/sample/resources/fix/FIX40-synapse.xml</div>
                            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.
                        </li>
                    </ul>
                </p>
            </subsection>
            <subsection name="Executing the Client">
                <p>
                    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.
                </p>                
            </subsection>
        </section>
        <p><a href="../samples.html">Back to Catalog</a></p>        
    </body>
</document>