原始消息我使用分離器拆分職位在單個消息。單個消息充滿了一些數據。拆分後,我想將所有消息合併到一個。但是當我這樣做時,我只能得到所有職位,而不是邊界XML。我怎樣才能得到在我的路由Splitter AggregateStrategy
我的XML:
<order>
<firstname>Max</firstname>
<lastname>Mustermann</lastname>
<positions>
<position>
<articlename>Article 1</articlename>
<amount>1</amount>
</position>
<position>
<articlename>Article 2</articlename>
<amount>2</amount>
</position>
</positions>
</order>
我的路線:
from("activemq:orders")
.split(body().tokenizeXML("POSITION",""), new AggregatePositionsStrategy())
.enrich("direct:getArticleNumber", new addArticleNrToPositionStrategy())
.end()
.to("file://c:/temp")
的路線後,我的XML是:
<position>
<articlenumber>654321</articlenumber>
<articlename>Article 1</articlename>
<amount>1</amount>
</position>
<position>
<articlenumber>123456</articlenumber>
<articlename>Article 2</articlename>
<amount>2</amount>
</position>
新的數據被插入,但訂單界丟失。我能做些什麼來獲取所有數據?
我AggregatePositionsStrategy的Splitter是:
public class AggregatePositionsStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange exchange, Exchange response) {
if (exchange == null) {
return response;
}
if (exchange.getIn().getHeader("Artikelnummer") != null && exchange.getIn().getHeader("Artikelnummer").equals("Not Found")) {
exchange.getIn().setHeader("Artikelnummer", "Not Found");
}
if (response.getIn().getHeader("Artikelnummer") != null && response.getIn().getHeader("Artikelnummer").equals("Not Found")) {
exchange.getIn().setHeader("Artikelnummer", "Not Found");
}
String orders = exchange.getIn().getBody(String.class);
String newLine = response.getIn().getBody(String.class);
orders = orders + "\n" + newLine;
exchange.getIn().setBody(orders);
return exchange;
}
}
我知道,我只是人體的從劈裂郵件複製。但我不知道如何獲得原始信息,以獲取所有部分。你有好主意嗎?
如果我不使用AggregateStrategy。分割後我得到原始的消息體,但沒有豐富的數據。 http://camel.apache.org/splitter.html#Splitter-WhattheSplitterreturns所以必須有原始的Message體到處 – Burner 2015-01-21 09:09:50