The use case is simply this: I need to poll and hit an HTTP endpoint with an initial "offset" param of -1. The response header contains a new offset ("NEXT_OFFSET") to use the next time I hit the endpoint.
Sounds simple enough... Until you start trying to do it... playing around with properties and headers, on and off the exchange, system properties, GlobalOptions, setting the initial value in a "calling" route instead of a class variable, etc, etc, etc. Finally I found a post with someone else asking the exact same question and there was a response from Claus that mentioned using inline processors and lambdas, which finally pointed me in the direction toward a solution. I still needed to figure out a few more things to actually do it. So, this is what I eventually implemented, and it works fine. But is it *really* the only way to communicate a value between a route and its RouteBuilder class? And can my snippet be simplified even more? In particular, note that I seemed to be required to use an intermediate header value ("offset") to store/retrieve the actual offset to the "offsetCache" class variable. Thanks. In my RouteBuilder configure(): AtomicReference<String> offsetCache = new AtomicReference<>("-1"); from("timer:mytimer?period={{polling.interval}}") .process(exchange -> exchange.getIn().setHeader("offset", offsetCache.get())) .toD("{{url.base}}/${header.offset}") // process the response and get the new offset from the header into the class variable .setHeader("offset", simple("${in.header.NEXT_OFFSET}")) .process(exchange -> offsetCache.set(exchange.getIn().getHeader("offset").toString()))