0
votes

I have this Camel Route:

    <route id="externalRestPushRoute">
        <from uri="jms:pushProcessedRecordsToExternal" />
        <setHeader headerName="PAYLOAD">
          <simple>body</simple>
        </setHeader>
        <marshal ref="jack"></marshal>
        <to uri="http://localhost/front/rest/karec/dummy-push"/>
        <transform>
            <simple>in.header[PAYLOAD]</simple>
        </transform>
        <to uri="bean:noAuthRecordPersistenceService?method=deliverySuccess" />
    </route>

The idea is this: I want to deliver an object in JSON format to a REST endpoint(all the headers are properly set and the rest endpoint receives the json format)/ To convert the object to JSON format I use marshal and it works. Now, the response back from the http endpoint is of type java.io.InputStream but I don't care. What I care is converting the body back to the original object before it was marshaled. I did save the object in a header before marshaling in a header named PAYLOAD. Now I want to use transform to get it back into the body of the message. Well, that does not seem to work. When it get to the last bean it complains that body is still of type java.io.InputStream.

1

1 Answers

1
votes

Stores the body on the exchange property instead of a header, that is safer.

    <setProperty propertyName="PAYLOAD">
      <simple>body</simple>
    </setProperty>


    <transform>
        <simple>${property.PAYLOAD}</simple>
    </transform>