首页 > 解决方案 > Apache Camel 的默认路由

问题描述

我正在使用 Apache Camel。使用 XML DSL,我的意思是

<rests id="rests" xmlns="http://camel.apache.org/schema/spring">
    <rest id="rest-custom">
        <get uri="my_method" method="">
            <description>...</description>
            <param name="..." ... />
            <route>
                <process ref="..." />
                <to uri="..." />
            </route>
        </get>

        <post uri="another_method" method="" >
            <description>...</description>
            <param name="..." .../>
            <route>
                <process ref="..." />
                <to uri="..." />
            </route>
        </post>
...

因此,如果我想要新路线,我将添加新的<get><post>它工作正常。

但现在我想添加一些DEFAULT方法。我的意思是,类似于<get uri="*"><post uri="*">在所有配置的底部。因此,如果我的网址与列表中的任何网址都不匹配 - 它会转到默认网址,我可以使用自定义处理器处理它(这是我想要的行为)。

目前我不知道,该怎么做。尝试处理 404 响应,但仍然没有成功。看起来解决方案应该很简单,但还找不到。

标签: javaapache-cameldsl

解决方案


终于找到了解决办法。

<get uri="/?matchOnUriPrefix=true&amp;bridgeEndpoint=true" method="">
    <description>Default GET method</description>
    <route>
       ...
    </route>
</get>

参数matchOnUriPrefix=true&bridgeEndpoint=true成功了。


推荐阅读