简体   繁体   中英

How to escape regex in Java methods call in simple language in Apache's Camel Spring DSL (XML) route?

I have a setHeader tag in my route:

<setHeader headerName="timestampPart3"><simple>${header.timestampPart2.split("\\.")[0]}</simple></setHeader>
<log message="After: ${body} ${headers}"/>

I expect, it will split the String inside the timestampPart2 header and take the first element.

In fact, it just ignores the splitting:

timestampPart2=114128.0, timestampPart3=114128.0

So how I should implement regex escaping in Spring DSL? If for some reason it is impossible, how to work that around?

To set an Exchange message header you would need to use the name field and not the headerName field:

<setHeader name="timestampPart3">
    <simple>${header.timestampPart2.split("\\.")[0]}</simple>
</setHeader>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM