I am trying to set a header parameter (param2
), using simple expression language:
from("timer://foo?repeatCount=1")
.setBody(constant("on,off"))
.split()
.tokenize(",")
.setHeader("param1", simple("${body}"))
.setHeader("param2", simple("${header.param1} == 'on'"))
.log("param1 = [${header.param1}], param2 = [${header.param2}]");
But as result I get a string set instead of a boolean value, the following gets logged:
param1 = [on], param2 = [on == 'on']
param1 = [off], param2 = [off == 'on']
I would expect it log:
param1 = [on], param2 = [true]
param1 = [off], param2 = [false]
Documentation writes, that it is possible to do comparison using simple
and I can get it working when doing choices:
from("timer://foo?repeatCount=1")
.setBody(constant("on,off"))
.split()
.tokenize(",")
.setHeader("param1", simple("${body}"))
.choice()
.when(simple("${header.param1} == 'on'"))
.setHeader("param2", constant(true))
.otherwise()
.setHeader("param2", constant(false))
.end()
.log("param1 = [${header.param1}], param2 = [${header.param2}]");
The output then is:
param1 = [on], param2 = [true]
param1 = [off], param2 = [false]
But why it is not working then in direct assignment?