Mule and QuickFIX/J integration
(configuration and code NOT be verified)
TODO
1. Declare the namespace, the following example just contains:mule, spring ,vm, and fix
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2" xmlns:fix="http://www.mulesource.org/schema/mule/fix/2.2" xsi:schemaLocation="http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd http://www.mulesource.org/schema/mule/fix/2.2 http://www.mulesource.org/schema/mule/fix/2.2/mule-fix.xsd">
2. Defined the fix connector and endpoint
a) Connector
<fix:connector name="fixConnector" config="./fix/fix-setting.cfg"/>
b) Endpoing
<fix:endpoint name="zhFixIncoming" sessionID="FIX.4.4:XMLHK-XMLZH"/> <fix:endpoint name="hkExFixIncoming" sessionID="FIX.4.4:XMLHK-HKEx"/>
Actually, the sessionID would be look like as FIX.4.4:XMLHK->XMLZH
3. Defined the message transformer(Optional)
4. Defined the fix session setting
Config the fix session setting, more info can refer to http://www.quickfixj.org/quickfixj/usermanual/usage/configuration.html
[default] FileStorePath=log/data FileLogPath=log/log ReconnectInterval=5 HeartBtInt=30 LogonTimeout=60 PersistMessages=Y [session] BeginString=FIX.4.4 ConnectionType=acceptor SenderCompID=XMLHK TargetCompID=XMLZH StartTime=00:00:00 EndTime=00:00:00 SocketAcceptAddress=192.168.1.1 SocketAccetpPort=3030 TimeZone=Asia/Hong_Kong [session] BeginString=FIX.4.4 ConnectionType=initiator SenderCompID=XMLHK TargetCompID=HKEx StartTime=00:00:00 EndTime=00:00:00 SocketConnectHost=192.168.1.2 SocketConnectPort=3031 TimeZone=Asia/Hong_Kong ResetOnLogon=Y
Note: the first session can be regard to a sell side and the other is a buy side.
5. The mule model and service.
<model> <service name="zhFixIncomingService"> <inbound> <inbound-endpoint ref="zhFixIncoming"/> </inbound> <component> <spring-object bean="zhFixIncomingMessageService" </component> <outbound> <pass-through-router> <outbound-endpoint ref="hkExFixIncoming"/> </pass-through-router> </outbound> </service> <service name="hkExFixIncomingService"> <inbound> <inbound-endpoint ref="hkExFixIncoming"/> </inbound> <component> <spring-object bean="hkExFixIncomingMessageService" </component> <outbound> <pass-through-router> <outbound-endpoint ref="zhFixIncoming" /> </pass-through-router> </outbound> </service> </model>
6. Spring bean configuration
<spring:bean id="zhFixIncomingMessageService" class="com…ZhFixIncomingMessageService"> </spring:bean> <spring:bean id="hkExFixIncomingMessageService" class="com…hkExFixIncomingMessageService"> </spring:bean>
7. Java code:
a) zhFixIncomingMessageService
public class ZhFixIncomingMessageService implements Callable{ public Object onCall(MuleEventContext context) throws MuleException { TODO all fix message from first session will be processed through this callback method. } }
b) hkExFixIncomingSerivce
public class HkFixIncomingMessageService implements Callable{ public Object onCall(MuleEventContext context) throws MuleException { TODO all fix message from second session will be processed through this callback method. } }
8. TODO