Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel 如何在上下文中基于条件设置管线生成器_Apache Camel_Spring Bean - Fatal编程技术网

Apache camel 如何在上下文中基于条件设置管线生成器

Apache camel 如何在上下文中基于条件设置管线生成器,apache-camel,spring-bean,Apache Camel,Spring Bean,在我现有的代码中,我的camelcontextbean中有两个路由生成器 <camelContext xmlns="http://camel.apache.org/schema/spring"> <routeBuilder ref="routeBuilder1" /> <routeBuilder ref="routeBuilder2" /> </camelContext> 我想根据系统配置属性中配置的标志值设置管线生成器 您可以在属性

在我现有的代码中,我的
camelcontext
bean中有两个路由生成器

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <routeBuilder ref="routeBuilder1" />
  <routeBuilder ref="routeBuilder2" />
</camelContext>


我想根据系统配置属性中配置的标志值设置管线生成器

您可以在属性中定义routeBuilder1.enabled=true,然后使用:

@Value("${routeBuilder1.enabled}")
private boolean routeEnabled;

@Override
public void configure() throws Exception {
    from("..")
    .autoStartup(routeEnabled)
    .to("...")
}

你想达到什么目标?为什么不直接使用路线?如果您的目标是向两条路由发送消息,则可以使用多播。不确定这是否是您需要的。@isaac.hazan我想根据系统属性选择根目录,这样它就可以在不再次生成war的情况下进行部署。在这里,路线1和路线2因其来源和目的地终点而完全不同。有时我可能需要同时启用这两个根。当我将routeEnabled的值设置为false时,我得到以下异常,无法找到具有此RouteBuilder引用的任何路由:RouteBuilderRef[routebuilder1]解决了该异常