0
我有一個駱駝路線(主路由),它調用一個soap web服務並將soap服務返回的結果存儲到數據庫中。我的駱駝環境如下。如何並行運行駱駝組件
<route id="HttpRoute">
<from uri="jetty:http://127.0.0.1:8889/Getdata"/>
<to uri="direct:start"/>
</route>
<route id="TimerRoute">
<from uri="timer://getdata?period=10000"/>
<to uri="direct:start"/>
</route>
<route id="main-route">
<from uri="direct:start"/>
<process ref="soapRequestGenerator" />
<marshal>
<jaxb contextPath="org.sample.camel" fragment="true" namespacePrefixRef="namespacePrefixMap"/>
</marshal>
<convertBodyTo type="java.lang.String"/>
<to uri="velocity:soapRequest.vm"/>
<setHeader headerName="operationName">
<constant>soapOperationName</constant>
</setHeader>
<to uri="cxf:bean:soapServiceEndpoint"/>
<convertBodyTo type="java.lang.String"/>
<process ref="soapResponseProcessor" /> //task-0
<setBody>
<simple>
insert into table(Id,col1,col2) values(:?id,:?val1,:?val2);
</simple>
</setBody>
<to uri="jdbc:dataSource?useHeadersAsParameters=true"/> //task-1
<to uri="velocity:soapResponse.vm"/> //task-2
</route>
現在有兩個選項調用主路由。
1)通過timer(TimerRoute)定時執行並調用main-route將數據存入數據庫。
2)通過http(REST)調用,它要求從SOAP服務返回的響應存儲到數據庫並返回給調用者(REST)。
現在我想,當通過HttpRoute調用,因爲它們是獨立並行執行任務1和任務2的主要路線。這兩個任務所需的數據可以在任務0中準備並存儲到標題中,但我不知道如何執行此操作。另外,當主路由通過TimerRoute調用時,我不想執行任務2。怎麼做 ?
我還希望在插入從soap服務接收的記錄之前檢入數據庫,以避免重複記錄到數據庫中。該檢查可以與肥皂服務呼叫並行執行(以增加吞吐量),並根據需要決定插入或更新天氣記錄。