Camel Separator Using Custom Separation Method

I may be doing something wrong here, but it seems I am not getting the expected result when using the split () combination. method. Incoming XML changes slightly between incoming messages, and the elementKey node inside it describes what XML node we are looking for inside it.

from("direct:fromWhereEver")
  ...
  .setHeader("dynamicToken", xpath("//*[local-name()='elementKey']/text()").stringResult())
  ...
  .split().method(DynamicSplitToken.class, "extractTokens")
    .to("direct:outgoing")
.routeId("BhahBlah")

I have the following defined in a method for use by a route

public class DynamicSplitToken {
    public static Expression extractTokens(Exchange exchange){

        String splitToken = exchange.getIn().getHeader("dynamicToken").toString();

        TokenizeLanguage tok = new TokenizeLanguage();
        tok.setXml(true);
        tok.setIncludeTokens(true);
        tok.setToken(splitToken);

        return tok.createExpression();
    }
}

Now the xml tags are removed from the message without problems, BUT the received "body", which is extracted and pushed, contains <tagname>...</tagname>that corresponds to the elementKey element above, without child nodes / elements between them. I would expect to get everything between tags, similar to how I used the following

.split().tokenizeXML("tagname")

, , {header.dynaimcToken} tokenizeXML ProcessorDefinition, .

, , , ,

2.9 (fuse-esb),

+3
1

method() Expresssion, -, , java.util.List, . . , evaluate , :

protected static class DynamicSplitToken {
    @SuppressWarnings("unchecked")
    public static List<String> extractTokens(final Exchange exchange) {
        final String splitToken = exchange.getIn().getHeader("dynamicToken").toString();

        final TokenizeLanguage tok = new TokenizeLanguage();
        tok.setXml(true);
        tok.setIncludeTokens(true);
        tok.setToken(splitToken);

        final Expression expression = tok.createExpression();
        return expression.evaluate(exchange, List.class);
    }
}
+3

All Articles