Camel : How to set matchOnUriPrefix=true for jetty component configured in <restConfiguration>

穿精又带淫゛_ 提交于 2020-06-29 11:26:14

问题


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

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

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>

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

Thanks


回答1:


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>

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




回答2:


U may add inside route

tag as below:

<route>
  <from uri="jetty://foo?matchOnUriPrefix=true"/>
  ...
</route>


来源:https://stackoverflow.com/questions/39341784/camel-how-to-set-matchonuriprefix-true-for-jetty-component-configured-in-rest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!