270.8. Spring 配置
Camel 2.6 - 2.8.x
QuickFIX/J 组件包含 Spring FactoryBean
,用于在 Spring 上下文中配置会话设置。还包括用于 QuickFIX/J 会话 ID 字符串的类型转换器。以下示例显示两个会话都有默认设置的接收器和启动器会话的简单配置。
<!-- camel route --> <camelContext xmlns="http://camel.apache.org/schema/spring" id="quickfixjContext"> <route> <from uri="quickfix:example"/> <filter> <simple>${in.header.EventCategory} == 'AppMessageReceived'</simple> <to uri="log:test"/> </filter> </route> </camelContext> <!-- quickfix component --> <bean id="quickfix" class="org.apache.camel.component.quickfixj.QuickfixjComponent"> <property name="engineSettings"> <util:map> <entry key="quickfix:example" value-ref="quickfixjSettings"/> </util:map> </property> <property name="messageFactory"> <bean class="org.apache.camel.component.quickfixj.QuickfixjSpringTest.CustomMessageFactory"/> </property> </bean> <!-- quickfix settings --> <bean id="quickfixjSettings" class="org.apache.camel.component.quickfixj.QuickfixjSettingsFactory"> <property name="defaultSettings"> <util:map> <entry key="SocketConnectProtocol" value="VM_PIPE"/> <entry key="SocketAcceptProtocol" value="VM_PIPE"/> <entry key="UseDataDictionary" value="N"/> </util:map> </property> <property name="sessionSettings"> <util:map> <entry key="FIX.4.2:INITIATOR->ACCEPTOR"> <util:map> <entry key="ConnectionType" value="initiator"/> <entry key="SocketConnectHost" value="localhost"/> <entry key="SocketConnectPort" value="5000"/> </util:map> </entry> <entry key="FIX.4.2:ACCEPTOR->INITIATOR"> <util:map> <entry key="ConnectionType" value="acceptor"/> <entry key="SocketAcceptPort" value="5000"/> </util:map> </entry> </util:map> </property> </bean>
Camel 2.9 公布
QuickFIX/J 组件包含用于配置会话设置的 QuickfixjConfiguration
类。还包括用于 QuickFIX/J 会话 ID 字符串的类型转换器。以下示例显示两个会话都有默认设置的接收器和启动器会话的简单配置。
<!-- camel route --> <camelContext id="quickfixjContext" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="quickfix:example"/> <filter> <simple>${in.header.EventCategory} == 'AppMessageReceived'</simple> <to uri="log:test"/> </filter> </route> <route> <from uri="vm:test"/> <to uri="lazyQuickfix:example"/> </route> </camelContext> <!-- quickfix component --> <bean id="quickfix" class="org.apache.camel.component.quickfixj.QuickfixjComponent"> <property name="configurations"> <util:map> <entry key="example" value-ref="quickfixjConfiguration"/> </util:map> </property> <property name="messageFactory"> <bean class="org.apache.camel.component.quickfixj.QuickfixjSpringTest.CustomMessageFactory"/> </property> </bean> <!-- lazy quickfix component --> <bean id="lazyQuickfix" class="org.apache.camel.component.quickfixj.QuickfixjComponent"> <property name="lazyCreateEngines" value="true" /> <property name="configurations"> <util:map> <entry key="example" value-ref="lazyQuickfixjConfiguration"/> </util:map> </property> <property name="messageFactory"> <bean class="org.apache.camel.component.quickfixj.QuickfixjSpringTest.CustomMessageFactory"/> </property> </bean> <!-- quickfix settings --> <bean id="quickfixjConfiguration" class="org.apache.camel.component.quickfixj.QuickfixjConfiguration"> <property name="defaultSettings"> <util:map> <entry key="SocketConnectProtocol" value="VM_PIPE"/> <entry key="SocketAcceptProtocol" value="VM_PIPE"/> <entry key="UseDataDictionary" value="N"/> </util:map> </property> <property name="sessionSettings"> <util:map> <entry key="FIX.4.2:INITIATOR->ACCEPTOR"> <util:map> <entry key="ConnectionType" value="initiator"/> <entry key="SocketConnectHost" value="localhost"/> <entry key="SocketConnectPort" value="5000"/> </util:map> </entry> <entry key="FIX.4.2:ACCEPTOR->INITIATOR"> <util:map> <entry key="ConnectionType" value="acceptor"/> <entry key="SocketAcceptPort" value="5000"/> </util:map> </entry> </util:map> </property> </bean>