0
我們有一個用例,我們需要從多個來源構建主xml。最初,我們將從服務中獲取xml,並使用此xml中的信息進行不同的數據庫調用以保存/獲取信息,最後構建主xml並保存到數據庫。我們使用帶有保險絲的駱駝。使用多個輸入構建xml
Here is our xml and camel routes.
<xml>
<xmlInformation>
.....
</xmlInformation>
<customers>
<customer>...</customer>
<customer>...</customer>
<customer>...</customer>
</customers>
<products>
<product>....<product>
<product>....<product>
<product>....<product>
</products>
</xml>
客戶和產品元素的數量是動態的,我們提取每一位客戶,產品從XML,保存到數據庫,並得到一些客戶,產品相關的ID和如下構建主XML。客戶分流的
<m:master>
<m:xmlInformation>....</m:xmlInformation>
<c:customers>
<c:customer id="12345">....</c:customer>
<c:customer id="22345">....</c:customer>
<c:customer id="32345">....</c:customer>
</c:customers>
<p:products>
<p:product id="22222">.....</p:product>
<p:product id="11111">.....</p:product>
<p:product id="33333">.....</p:product>
</p:products>
</m:master>
Here is came route
<route id="routeA">
<from uri="direct-vm:saveMasterXml" />
<setProperty propertyName="originalIUPayload"><simple>${body}</simple></setProperty>
<splitter parallelProcessing=true stopOnException=true strategyRef="customersAggregator" >
<xpath>/xml/customers/customer</xpath>
<bean ref="customerService" method="saveCustomer" />
</splitter>
<setProperty propertyName="customerXmls"><simple>${body}</simple></setProperty>
<setBody><simple>${property.originalIUPayload}</simple></setBody>
<splitter parallelProcessing=true stopOnException=true strategyRef="productsAggregator" >
<xpath>/xml/products/product</xpath>
<bean ref="productService" method="getProductIds" />
</splitter>
<setProperty propertyName="productIds"><simple>${body}</simple></setProperty>
<setBody><simple>${property.originalIUPayload}</simple></setBody>
<!-- transformation -->
<bean ref="masterService" method="saveMasterXml" />
</route>
輸出與IDS和產物分流器的輸出是產品ID列表豐富客戶的個XML列表。我可以使用xslt構建主xml,因爲大多數xml元素都是原始xml,但客戶和產品列表中的id需要傳遞給xslt。我被困在這裏解決它。歡迎任何建議。