Hi folks,

I am having a problem migrating a working Java DSL config to XML.

Any help is greatly appreciated.

Camel version:
2.23.2

The working Java routes:

        from("direct://syncService")
            .routeId("syncService")
            .setHeader(Exchange.HTTP_METHOD, constant("GET"))
            .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
            .setProperty("aggregateSchemaId",
simple("${in.body[\"aggregateSchemaId?\"]}"))
            .setProperty("aggregateInstanceId",
simple("${in.body[\"aggregateInstanceId?\"]}"))
            .marshal().json()
            .toD("
http://localhost:8082/korio-rest/task/getData/${exchangeProperty.aggregateSchemaId}/${exchangeProperty.aggregateInstanceId}
")
            .unmarshal().json(Map.class, null)
            .setBody(simple("${in.body}"));

OR

        from("direct://syncService")
            .routeId("syncService")
            .setHeader(Exchange.HTTP_METHOD, constant("GET"))
            .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
            .setProperty("aggregateSchemaId",
simple("${in.body[\"aggregateSchemaId?\"]}"))
            .setProperty("aggregateInstanceId",
simple("${in.body[\"aggregateInstanceId?\"]}"))
            .marshal().json()
            .toD("
http://localhost:8082/korio-rest/task/getData/${exchangeProperty.aggregateSchemaId}/${exchangeProperty.aggregateInstanceId}
")
            .unmarshal().json(Map.class, null)
            .process("syncResultProcessor");

Where syncResultProcessor is a Spring bean reference which is called
successfully.


However neither of these XML route configs work:

<route id="syncService">
    <from uri="direct://syncService"/>
    <setHeader
headerName="$simple{type:org.apache.camel.Exchange.HTTP_METHOD}">
        <constant>GET</constant>
    </setHeader>
    <setHeader
headerName="$simple{type:org.apache.camel.Exchange.CONTENT_TYPE}">
        <constant>application/json</constant>
    </setHeader>
    <setProperty propertyName="aggregateSchemaId">
        <simple>
            ${in.body["aggregateSchemaId?"]}
        </simple>
    </setProperty>
    <setProperty propertyName="aggregateInstanceId">
        <simple>
            ${in.body["aggregateInstanceId?"]}
        </simple>
    </setProperty>
    <marshal>
        <json/>
    </marshal>
    <toD uri="
http://localhost:8082/korio-rest/task/getData/${exchangeProperty.aggregateSchemaId}/${exchangeProperty.aggregateInstanceId}
"/>
    <unmarshal>
        <json unmarshalTypeName="java.util.Map" jsonView="null"/>
    </unmarshal>
    <setBody>
        <simple>
            ${in.body}
        </simple>
    </setBody>
</route>


OR


<route id="syncService">
    <from uri="direct://syncService"/>
    <setHeader
headerName="$simple{type:org.apache.camel.Exchange.HTTP_METHOD}">
        <constant>GET</constant>
    </setHeader>
    <setHeader
headerName="$simple{type:org.apache.camel.Exchange.CONTENT_TYPE}">
        <constant>application/json</constant>
    </setHeader>
    <setProperty propertyName="aggregateSchemaId">
        <simple>
            ${in.body["aggregateSchemaId?"]}
        </simple>
    </setProperty>
    <setProperty propertyName="aggregateInstanceId">
        <simple>
            ${in.body["aggregateInstanceId?"]}
        </simple>
    </setProperty>
    <marshal>
        <json/>
    </marshal>
    <toD uri="
http://localhost:8082/korio-rest/task/getData/${exchangeProperty.aggregateSchemaId}/${exchangeProperty.aggregateInstanceId}
"/>
    <unmarshal>
        <json unmarshalTypeName="java.util.Map" jsonView="null"/>
    </unmarshal>
    <process ref="syncResultProcessor"/>
</route>

I.e. even the processor is not called.

Interesting that if the processor is moved up to be invoked before
unmarshal it does get called.
Seems that unmarshal is terminating the route flow somehow...


Thanks,
Andrey.

Reply via email to