【问题标题】:Apache Camel: Query Params vs Header ParamsApache Camel:查询参数与标头参数
【发布时间】:2013-04-11 03:26:14
【问题描述】:

我目前正在试用 Apache camel(作为路由引擎)。我了解 Camel 支持多种 DSL,并且可以使用 Java (Java DSL) 或 Spring (Spring DSL) 进行配置。

问题:
我有以下 Spring DSL 配置。这个想法是,如果传入的请求具有名为“name”的标头参数,它将命中 when 子句,否则会将请求路由到 google:

 <camel:route>
    <camel:from uri="servlet:///test" />
    <camel:choice>
        <camel:when>
            <camel:header>name</camel:header>
            <camel:transform>
                <camel:simple>Hello ${header.name} how are you?</camel:simple>
            </camel:transform>
        </camel:when>
        <camel:otherwise>
                <camel:to uri="http://www.google.com?bridgeEndpoint=true" />
        </camel:otherwise>
    </camel:choice>
</camel:route>

我希望上述配置仅适用于 Header Param。但是,我注意到此配置甚至适用于查询参数,如以下请求所示:

http://localhost:8080/<war-context>/test?name=test

有没有办法确保它只适用于标题参数?

【问题讨论】:

    标签: java http-headers apache-camel query-parameters spring-dsl


    【解决方案1】:

    有据可查 here 查询参数被复制到 servlet 组件中的交换标头。

    【讨论】:

    猜你喜欢
    • 2016-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多