Camel blueprint setHeader complains about headerName and name at the same time

Viewed 522

I have the following camel blueprint

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0           
    https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd                                      
    http://camel.apache.org/schema/blueprint           
    https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    
    <bean class="ph.edu.dlsu.esb.GGMockProcessor" id="GGMockProcessor"/>
    <bean class="ph.edu.dlsu.esb.CogProcessor" id="CogProcessor"/>
    <cm:property-placeholder id="camugetgrade.properties"
        persistent-id="camugetgrade" update-strategy="reload">
        <cm:default-properties>
            ...
        </cm:default-properties>
    </cm:property-placeholder>
    <camelContext id="_getgradecontext2" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="_getgrade2">
            <from id="_from1" uri="netty4-http:{{server.protocol}}:{{server.host}}:{{server.port}}{{server.path}}">
                <description>Receives Current Grade from Camu</description>
            </from>
            <process id="_process1" ref="CogProcessor"/>
            <log id="_coglog1" message="GGLog1 message headers = ${headers}">
                <description>The request raw from bpms</description>
            </log>
            <choice id="_choice1">
                <when id="_when1">
                    <simple>${header.callerAddress} == '{{caller.address.test}}'</simple>
                    <!-- Ok good ip address let's do it. -->
                    <log id="log2" message="Ok Good Test Address let's do it"/>
                    <setHeader name="api-key" id="_setHeader1">
                        <constant>{{api.key}}</constant>
                    </setHeader>
                    <setHeader name="accept-encoding" id="_setHeader2">
                        <constant>'gzip, deflate, br'</constant>
                    </setHeader>
                    <removeHeader headerName="x-forwarded-for" id="_removeHeaders1"/>
                    <!-- When the Camu Atomic Service is implemented this will change to the direct-vm:camuatomicservice  -->
                    <to id="_to2" uri="netty4-http:{{client.protocol}}:{{client.host}}:{{client.port}}/{{client.path}}"/>
                </when>
                <when id="_when2">
                    <simple>${header.callerAddress} == '{{caller.address.prod}}'</simple>
                    <!-- Ok good ip address let's do it. -->
                    <log id="log2" message="Ok Good Prod Address let's do it"/>            
                    <setHeader name="api-key" id="_setapikeyheader">
                        <constant>{{api.key}}</constant>
                    </setHeader>
                    <setHeader name="accept-encoding" id="_setHeader2">
                        <constant>'gzip, deflate, br'</constant>
                    </setHeader>
                    <removeHeader headerName="x-forwarded-for" id="_removeHeaders1"/>
                    <!-- When the Camu Atomic Service is implemented this will change to the direct-vm:camuatomicservice  -->
                    <to id="_to2" uri="netty4-http:{{client.protocol}}:{{client.host}}:{{client.port}}/{{client.path}}"/>
                </when>
                <otherwise id="_otherwise1">
                    <log id="log3" message="Uh Oh Otherwise"/>
                    <!-- Ok bad address don't set api-key and don't call camu, do some error stuff -->
                    <setBody id="_setBody1">
                        <constant>Failed caller.address matching</constant>
                    </setBody>
                </otherwise>
            </choice>
        </route>
        <!-- Moved from separate bundle to allow for self testing. -->
        <route id="_GetGMockroute1">
            <from id="_from2" uri="netty4-http:http:{{client.host}}:{{client.port}}/{{client.path}}"/>
            <log id="_GGlog1" message="GetGMockRoute in  body = ${body}"/>
            <process id="_process2" ref="GGMockProcessor"/>
            <log id="_GGlog2" message="GetGMockRoute out body = ${body}"/>
        </route>
    </camelContext>
</blueprint>

If I use code assist Ctrl-Space I get...

<setHeader headerName="test">
    <constant>blabla</constant>
</setHeader>

But when I save I get a red x error...

Multiple annotations found at this line:
    - cvc-complex-type.3.2.2: Attribute 'headerName' is not allowed to appear in element 
     'setHeader'.
    - cvc-complex-type.4: Attribute 'name' must appear on element 'setHeader'.

If I change it from headerName to name the red x changes but a caution says

Parameter headerName is a mandatory field and cannot be empty.

I have seen other posts on this problem, but the answers are related to spring and I am not using spring so the suggestions do not apply.

Obviously it cannot require both and either one throws an error or caution. Seems like a common problem lately but no solution other than spring.

2 Answers

All versions of CodeReady after 12.14 run on JDK 11 vs. JDK 8 in CodeReady 12.14 runs on JDK 8. So even though the camel-blueprint doesn't change that much on Fuse-Karaf 7.3 to 7.8 with camel in version 2.x when I reverted to CodeReady 12.14 and Fuse-Karaf 7.6 everything worked as expected. I still think it is a bad technique to change an interface like setHeader to go from unambiguous 'headerName' to just ambiguous 'name' and caused me a lot of wasted time. At least I found the solution and hope it helps others that run into the same problem.

Related