130.12. 使用命名参数
在以下给定路由中,我们希望从 projects 表中获取所有项目。请注意,SQL 查询有 2 个命名的参数::#lic 和 :#min。
然后,Camel 将从消息正文或消息标头中查找这些参数。请注意,在上面的示例中,为命名参数设置两个带有恒定值的标头
:
from("direct:projects")
.setHeader("lic", constant("ASF"))
.setHeader("min", constant(123))
.to("sql:select * from projects where license = :#lic and id > :#min order by id")
from("direct:projects")
.setHeader("lic", constant("ASF"))
.setHeader("min", constant(123))
.to("sql:select * from projects where license = :#lic and id > :#min order by id")
虽然消息正文是 java.util.Map,则 named 参数将从正文中获取。
from("direct:projects")
.to("sql:select * from projects where license = :#lic and id > :#min order by id")
from("direct:projects")
.to("sql:select * from projects where license = :#lic and id > :#min order by id")