如何在 Spring DSL(XML 路由配置)中为拆分中的 Apache Camel 同时使用标记化和简单?
How to use both tokenize and simple in Spring DSL (XML route config) for Apache Camel in split?
我想用 XML 重现来自 Java DSL 的表达式,如下所示:
from("direct:a")
.split(body(String.class).tokenize("\n"))
.to("direct:b");
当我尝试设置 , 由两个元素组成,并且像这样:
<split><tokenize token=\"#@#\"><simple>${bodyAs(java.lang.String)} not contains ''</simple></tokenize></split>
或者像那样:
<split><simple>${bodyAs(java.lang.String)} not contains ''</simple><tokenize token=\"#@#\"></tokenize><split>
它不允许使用以下方案验证 XML:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 488; cvc-complex-type.2.2: Element 'tokenize' must have no element [children], and the value must be valid.
和
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 475; cvc-complex-type.2.4.a: Invalid content was found starting with element 'tokenize'. One of '{\"http://camel.apache.org/schema/spring\":aggregate, \"http://camel.apache.org/schema/spring\":bean, \"http://camel.apache.org/schema/spring\":doCatch, \"http://camel.apache.org/schema/spring\":when, \"http://camel.apache.org/schema/spring\":choice, \"http://camel.apache.org/schema/spring\":otherwise, \"http://camel.apache.org/schema/spring\":circuitBreaker, \"http://camel.apache.org/schema/spring\":claimCheck, \"http://camel.apache.org/schema/spring\":convertBodyTo, \"http://camel.apache.org/schema/spring\":delay, \"http://camel.apache.org/schema/spring\":dynamicRouter, \"http://camel.apache.org/schema/spring\":enrich, \"http://camel.apache.org/schema/spring\":filter, \"http://camel.apache.org/schema/spring\":doFinally, \"http://camel.apache.org/schema/spring\":idempotentConsumer, \"http://camel.apache.org/schema/spring\":inOnly, \"http://camel.apache.org/schema/spring\":inOut, \"http://camel.apache.org/schema/spring\":intercept, \"http://camel.apache.org/schema/spring\":interceptFrom, \"http://camel.apache.org/schema/spring\":interceptSendToEndpoint, \"http://camel.apache.org/schema/spring\":loadBalance, \"http://camel.apache.org/schema/spring\":log, \"http://camel.apache.org/schema/spring\":loop, \"http://camel.apache.org/schema/spring\":marshal, \"http://camel.apache.org/schema/spring\":multicast, \"http://camel.apache.org/schema/spring\":onCompletion, \"http://camel.apache.org/schema/spring\":onException, \"http://camel.apache.org/schema/spring\":onFallback, \"http://camel.apache.org/schema/spring\":pipeline, \"http://camel.apache.org/schema/spring\":policy, \"http://camel.apache.org/schema/spring\":pollEnrich, \"http://camel.apache.org/schema/spring\":process, \"http://camel.apache.org/schema/spring\":recipientList, \"http://camel.apache.org/schema/spring\":removeHeader, \"http://camel.apache.org/schema/spring\":removeHeaders, \"http://camel.apache.org/schema/spring\":removeProperties, \"http://camel.apache.org/schema/spring\":removeProperty, \"http://camel.apache.org/schema/spring\":resequence, \"http://camel.apache.org/schema/spring\":rollback, \"http://camel.apache.org/schema/spring\":route, \"http://camel.apache.org/schema/spring\":routingSlip, \"http://camel.apache.org/schema/spring\":saga, \"http://camel.apache.org/schema/spring\":sample, \"http://camel.apache.org/schema/spring\":script, \"http://camel.apache.org/schema/spring\":setBody, \"http://camel.apache.org/schema/spring\":setExchangePattern, \"http://camel.apache.org/schema/spring\":setHeader, \"http://camel.apache.org/schema/spring\":setProperty, \"http://camel.apache.org/schema/spring\":sort, \"http://camel.apache.org/schema/spring\":split, \"http://camel.apache.org/schema/spring\":step, \"http://camel.apache.org/schema/spring\":stop, \"http://camel.apache.org/schema/spring\":threads, \"http://camel.apache.org/schema/spring\":throttle, \"http://camel.apache.org/schema/spring\":throwException, \"http://camel.apache.org/schema/spring\":to, \"http://camel.apache.org/schema/spring\":toD, \"http://camel.apache.org/schema/spring\":transacted, \"http://camel.apache.org/schema/spring\":transform, \"http://camel.apache.org/schema/spring\":doTry, \"http://camel.apache.org/schema/spring\":unmarshal, \"http://camel.apache.org/schema/spring\":validate, \"http://camel.apache.org/schema/spring\":whenSkipSendToEndpoint, \"http://camel.apache.org/schema/spring\":wireTap, \"http://camel.apache.org/schema/spring\":serviceCall}' is expected.
那么,XML不可能把simple和tokenize放在一起,那怎么办呢?
令人惊讶的是,它对
有效
<split><tokenize token=\"#@#\">${bodyAs(java.lang.String)} contains '#@#'</tokenize></split>
即<tokenize/>
可以有一个正文,其解释方式与 <simple/>
相同
我想用 XML 重现来自 Java DSL 的表达式,如下所示:
from("direct:a")
.split(body(String.class).tokenize("\n"))
.to("direct:b");
当我尝试设置 , 由两个元素组成,并且像这样:
<split><tokenize token=\"#@#\"><simple>${bodyAs(java.lang.String)} not contains ''</simple></tokenize></split>
或者像那样:
<split><simple>${bodyAs(java.lang.String)} not contains ''</simple><tokenize token=\"#@#\"></tokenize><split>
它不允许使用以下方案验证 XML:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 488; cvc-complex-type.2.2: Element 'tokenize' must have no element [children], and the value must be valid.
和
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 475; cvc-complex-type.2.4.a: Invalid content was found starting with element 'tokenize'. One of '{\"http://camel.apache.org/schema/spring\":aggregate, \"http://camel.apache.org/schema/spring\":bean, \"http://camel.apache.org/schema/spring\":doCatch, \"http://camel.apache.org/schema/spring\":when, \"http://camel.apache.org/schema/spring\":choice, \"http://camel.apache.org/schema/spring\":otherwise, \"http://camel.apache.org/schema/spring\":circuitBreaker, \"http://camel.apache.org/schema/spring\":claimCheck, \"http://camel.apache.org/schema/spring\":convertBodyTo, \"http://camel.apache.org/schema/spring\":delay, \"http://camel.apache.org/schema/spring\":dynamicRouter, \"http://camel.apache.org/schema/spring\":enrich, \"http://camel.apache.org/schema/spring\":filter, \"http://camel.apache.org/schema/spring\":doFinally, \"http://camel.apache.org/schema/spring\":idempotentConsumer, \"http://camel.apache.org/schema/spring\":inOnly, \"http://camel.apache.org/schema/spring\":inOut, \"http://camel.apache.org/schema/spring\":intercept, \"http://camel.apache.org/schema/spring\":interceptFrom, \"http://camel.apache.org/schema/spring\":interceptSendToEndpoint, \"http://camel.apache.org/schema/spring\":loadBalance, \"http://camel.apache.org/schema/spring\":log, \"http://camel.apache.org/schema/spring\":loop, \"http://camel.apache.org/schema/spring\":marshal, \"http://camel.apache.org/schema/spring\":multicast, \"http://camel.apache.org/schema/spring\":onCompletion, \"http://camel.apache.org/schema/spring\":onException, \"http://camel.apache.org/schema/spring\":onFallback, \"http://camel.apache.org/schema/spring\":pipeline, \"http://camel.apache.org/schema/spring\":policy, \"http://camel.apache.org/schema/spring\":pollEnrich, \"http://camel.apache.org/schema/spring\":process, \"http://camel.apache.org/schema/spring\":recipientList, \"http://camel.apache.org/schema/spring\":removeHeader, \"http://camel.apache.org/schema/spring\":removeHeaders, \"http://camel.apache.org/schema/spring\":removeProperties, \"http://camel.apache.org/schema/spring\":removeProperty, \"http://camel.apache.org/schema/spring\":resequence, \"http://camel.apache.org/schema/spring\":rollback, \"http://camel.apache.org/schema/spring\":route, \"http://camel.apache.org/schema/spring\":routingSlip, \"http://camel.apache.org/schema/spring\":saga, \"http://camel.apache.org/schema/spring\":sample, \"http://camel.apache.org/schema/spring\":script, \"http://camel.apache.org/schema/spring\":setBody, \"http://camel.apache.org/schema/spring\":setExchangePattern, \"http://camel.apache.org/schema/spring\":setHeader, \"http://camel.apache.org/schema/spring\":setProperty, \"http://camel.apache.org/schema/spring\":sort, \"http://camel.apache.org/schema/spring\":split, \"http://camel.apache.org/schema/spring\":step, \"http://camel.apache.org/schema/spring\":stop, \"http://camel.apache.org/schema/spring\":threads, \"http://camel.apache.org/schema/spring\":throttle, \"http://camel.apache.org/schema/spring\":throwException, \"http://camel.apache.org/schema/spring\":to, \"http://camel.apache.org/schema/spring\":toD, \"http://camel.apache.org/schema/spring\":transacted, \"http://camel.apache.org/schema/spring\":transform, \"http://camel.apache.org/schema/spring\":doTry, \"http://camel.apache.org/schema/spring\":unmarshal, \"http://camel.apache.org/schema/spring\":validate, \"http://camel.apache.org/schema/spring\":whenSkipSendToEndpoint, \"http://camel.apache.org/schema/spring\":wireTap, \"http://camel.apache.org/schema/spring\":serviceCall}' is expected.
那么,XML不可能把simple和tokenize放在一起,那怎么办呢?
令人惊讶的是,它对
有效<split><tokenize token=\"#@#\">${bodyAs(java.lang.String)} contains '#@#'</tokenize></split>
即<tokenize/>
可以有一个正文,其解释方式与 <simple/>