270.8. Spring 설정

Camel 2.6 - 2.8.x

QuickFIX/J 구성 요소에는 Spring 컨텍스트 내에서 세션 설정을 구성하는 Spring FactoryBean 이 포함되어 있습니다. 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>