Apache Camel: how store variable for later use

前端 未结 2 962
情话喂你
情话喂你 2021-02-07 05:27

while \'playing around\' with Camel using Spring DSL, I came across the following problem. Suppose the expected message flow looks like this:

  1. client sends HTTP POS
2条回答
  •  旧巷少年郎
    2021-02-07 05:40

    you can set store data in the Exchange properties or message headers like this...

    .setHeader("ID", XPathBuilder.xpath("/order/@id", String.class))
    .setProperty("ID", XPathBuilder.xpath("/order/@id", String.class))
    

    and then retrieve them in a bean/processor from the Exchange like this...

    String propId = (String) exchange.getProperty("ID");
    String headerId = (String) exchange.getIn().getHeader("ID");                        }
    

提交回复
热议问题