Apache camel 以其他方式停止路线

Apache camel 以其他方式停止路线,apache-camel,Apache Camel,嗨,有这样的路线吗 <route id="route1"> <from uri="activemq:queuer1"/> <choice> <when> <simple>${header.urn} regex '^user*'</simple> <to uri="xslt:classpath:/xslt/rdf/user.xsl"/>

嗨,有这样的路线吗

<route id="route1">
<from uri="activemq:queuer1"/>
    <choice>
        <when>
            <simple>${header.urn} regex '^user*'</simple>
            <to uri="xslt:classpath:/xslt/rdf/user.xsl"/>
        </when>
        <when>
            <simple>${header.urn} regex '^userdata:.*'</simple>
            <to uri="xslt:classpath:/xslt/rdf/userdata.xsl"/>
        </when>
        ....
        <otherwise>
            <setHeader headerName="errorMsg ">
                <constant>no xsl file for this type</constant>
            </setHeader>
            <to uri="activemq:error"/>
        </otherwise> 
    </choice>
    <process ref="importer"/>
</route>

${header.urn}regex“^user*”
${header.urn}regex“^userdata:*”
....
此类型没有xsl文件
现在,如果路由进入“否则”部分,则不应处理消息。 如果信息进入了网络,我是否可以停止路由

我可能会在所有when部分中添加流程部分,并在最后删除它。 但我们已经有了几个when部件,还有更多

最好使用其他解决方案。

您可以添加一个
来停止继续路由邮件

在Java代码中:

exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
在Java DSL中:

.when(simple("${in.header.CamelHttpResponseCode} == 404"))
    .stop()
.otherwise()
    ...

这是一种非常有用的技术。是否可以将此文档添加到Camel网站?它可能已经在那里了,但我找不到。我在文档中也找不到,尽管克劳斯的书中有一个例子。这个来源可能会有帮助: