Global options are not for storing arbitrary end user stuff really.
Its for some global options for Camel itself for some logging max
sizes, and some other bits.
That said the options are stored as key/values as-is and not evaluated
during routing of an exchange as they are not intended for that.

But if you want to do it anyway, then your process method can store
the body size as a value instead of a simple text.

Something ala .put("xxx", exchange.getMessage.getBody.size)


On Fri, May 1, 2020 at 6:24 AM Ron Cecchini <roncecch...@comcast.net> wrote:
>
> I'm trying to pass back the # of things I've processed in a route back to the 
> calling Java.
>
> This log() displays the correct number:
>
> .log(LoggingLevel.INFO, "Processing ${body.size} Things ...")
>
> I then tried putting that ${body.size} in a GlobalOption on the CamelContext 
> so I can access it later:
>
> .process(exchange -> 
> exchange.getContext().getGlobalOptions().put("NumThings", 
> simple("${body.size}").toString()) )
>
> However, the above, and a few variations of the simple(), causes this:
>
> System.out.println(String.format("*** Processed %s Things", 
> camContext.getGlobalOption("NumThings")));
>
> to gives this:
>
> *** Processed Simple: ${body.size} Things
>
> I just can't figure out how to do the evaluations and get that value in the 
> GlobalOptions.  (I googled and googled...)
>
> Or maybe there's a better way to store it in the CamelContext?
>
> Thanks.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to