Camel:如何为 <restConfiguration> 中配置的 jetty 组件设置 matchOnUriPrefix=true [英] Camel : How to set matchOnUriPrefix=true for jetty component configured in &lt;restConfiguration&gt;

查看:23
本文介绍了Camel:如何为 <restConfiguration> 中配置的 jetty 组件设置 matchOnUriPrefix=true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下骆驼路由配置.

I have following camel routing configuration.

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

<!-- Rest Configuration -->
<restConfiguration component="jetty" port="9092" bindingMode="auto">
    <dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES" />
</restConfiguration>

<rest path="/" consumes="application/json"
        produces="application/json">
        <post uri="/" type="com.aaa.xxxx.esb.config.xxxxEsbJsonMapping">
            <route>
                <setHeader headerName="Authorization">
                    <simple>Basic YWRtaXXXXWRtaW4=</simple>
                </setHeader>
                <setHeader headerName="CamelHttpMethod">
                    <constant>POST</constant>
                </setHeader>

                <setHeader headerName="CamelHttpMethod">
                    <constant>POST</constant>
                </setHeader>

                <setHeader headerName="RestEndpointURL">
                    <simple>
                        http://${body.serviceURL}?bridgeEndpoint=true
                    </simple>
                </setHeader>
                <setBody>
                    <simple>{"UserDetails": ${body.serviceDataJsonObj}}</simple>
                </setBody>

                <log message="Exchanged headers : ${headers.RestEndpointURL}" />

                <recipientList>
                    <simple>${headers.RestEndpointURL}</simple>
                </recipientList>

            </route>
        </post>
    </rest>

我需要知道的是我可以在哪里设置

What I need to know is where I can set

matchOnUriPrefix=true

matchOnUriPrefix=true

我已经为骆驼休息配置的码头组件的选项.

option for the jetty component which I have already configured for camel rest.

根据 Claus Ibsen 的回答,我将配置 XML 更改如下.

According to the Claus Ibsen answer, I changed configuration XML as follows.

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

    <!-- Rest Configuration -->
    <restConfiguration component="jetty" port="9092"
        bindingMode="auto">
        <dataFormatProperty key="json.in.disableFeatures"
            value="FAIL_ON_UNKNOWN_PROPERTIES" />
        <componentProperty key="matchOnUriPrefix" value="true" />
    </restConfiguration>

    <!-- Rest Services -->
<rest path="/" consumes="application/json" produces="application/json">
        <post uri="/" type="com.aaa.xxxx.esb.config.xxxxEsbJsonMapping">
            <route>
                <setHeader headerName="Authorization">
                    <simple>Basic YWRXXX46YWRtaW4=</simple>
                </setHeader>
                <setHeader headerName="CamelHttpMethod">
                    <constant>POST</constant>
                </setHeader>

                <setHeader headerName="CamelHttpMethod">
                    <constant>POST</constant>
                </setHeader>

                <setHeader headerName="RestEndpointURL">
                    <simple>
                        http://${body.serviceURL}?bridgeEndpoint=true
                    </simple>
                </setHeader>
                <setBody>
                    <simple>{"SystemUserDetails": ${body.serviceDataJsonObj}}</simple>
                </setBody>

                <log message="Exchanged headers : ${headers.RestEndpointURL}" />

                <recipientList>
                    <simple>${headers.RestEndpointURL}</simple>
                </recipientList>

            </route>
        </post>
    </rest>

</camelContext>

我正在使用 servicemix apache-servicemix-7.0.0.M2我将它的骆驼版本 2.16.3 升级到 2.17.3

I'm using servicemix apache-servicemix-7.0.0.M2 I upgraded its camel ver 2.16.3 to 2.17.3

谢谢

推荐答案

rest-dsl 是使用 restConfiguration 中的 componentProperty 配置的:

The rest-dsl is configured using the componentProperty in the restConfiguration:

<restConfiguration component="jetty" port="9092" bindingMode="auto">
    <componentProperty key="matchOnUriPrefix" value="true"/>
    <dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES" />
</restConfiguration>

您可以在文档中找到有关此的详细信息:http://camel.apache.org/rest-dsl

You can find details about this in the documentation: http://camel.apache.org/rest-dsl

这篇关于Camel:如何为 <restConfiguration> 中配置的 jetty 组件设置 matchOnUriPrefix=true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆