我有如下所示的RouteBuilder。
from("seda:requestQueue").routeId("service_request").log(LoggingLevel.INFO, "Processing STARTED, {body = ${body}")
.setBody(body())
.to("select * from SERVICE_REQUEST WHERE requestType=:#TYPE AND requestDate=:#date AND owner=:#OWNER)
.split(body()).streaming().process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Map<String, Object> row = exchange.getIn().getBody(Map.class);
if (row == null) {
LOGGER.info("Request is new. No records found.");
return;
}
//Duplicate request. Q(Not sure how to terminate the process with exception)
}
})
.log(LoggingLevel.INFO, "Processing CONTINUE, {body = ${body}")
.setBody(body())
.to("insert into SERVICE_REQUEST (ID,....) ").log(LoggingLevel.INFO, "Processing COMPLETED").end();
我想实现
问题: 1.如何设置原始请求正文为insertQuery?按照上面的代码,在seda:requestQueue处接收到的正文不可用于(“插入SERVICE ..)。”
答案 0 :(得分:0)
您的拆分器将发送带有新正文的消息(基于SQL)。因此,身体本身无法使用。
相反,在调用拆分器之前,请将正文设置为Exchange的属性。然后,当您需要使用它时,请读取该属性的值。
.setProperty("mySampleProperty", simple("${body}")
如果您需要将其作为正文,则在那时-将正文设置为先前存储在Exchange属性中的值。