在路由中指定 URI 时是否可以使用 SpEL? 我已经尝试了几种方法,但似乎不起作用。
想做这样的事情:
<from uri="jms:queue:#{ ${mq.dynamic.switch} ? '$mq.dynamic.queue' : '$mq.static.queue'}?connectionFactory=#connectionFactory" />
我本质上是在尝试评估一个属性,以确定在配置 JMS 路由时要利用哪些队列。
不,这在<from>
是不可能的。你可以使用骆驼的属性占位符:http://camel.apache.org/using-propertyplaceholder.html
在 Camel 路由(如 <to>
)中,您可以使用"dynamic-to",它允许使用任何脚本语言,例如 SpEL:
- http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html
- http://camel.apache.org/languages.html