Reputation: 2486
I have two Apache Camel Routers in a Docker Network.
The one acts as client and sends some data in the body to the outer with a route.
I now want to get the modified body from the server router.
But apparently the body modification is never applied.
(For context the initial request is a post request where the final body should be the response)
Here is how my "client" route looks like:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="restlet" bindingMode="json" port="8989" enableCORS="true"/>
<rest path="/finData">
<description>User rest service</description>
<post>
<to uri="direct:update"/>
</post>
</rest>
<route id="sendFinData">
<from uri="direct:update"/>
<log message="Got some data: ${body}"/>
<to uri="aclient://otherClient:9191"/>
</route>
And here is how the "server" looks like:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="receiveFinData">
<from
uri="aserver://0.0.0.0:9191"/>
<log message="Received via data: ${body}"/>
<setBody>
<simple>{"result": true }</simple>
</setBody>
</route>
Update: If I add a second route to the "client" and call this one instead the external of the "server" and modify the body there it is working
Upvotes: 0
Views: 1279
Reputation: 7035
Update due to comments: When the setBody
is not the problem, then I have to ask about the flow in the code.
/finData
to send a request from the client to the server? aclient://otherClient:9191
? This route is not in your question. aserver://0.0.0.0:9191
is also not in your question. Can you post the whole flow?
Original answer
I think @tadayoshi-sato already commented the solution to your problem.
You use the Camel Simple language (an Expression Language) to set a constant string into your message body.
Use the Camel Constant language instead.
<setBody>
<constant>{"result": true }</constant>
</setBody>
Upvotes: 1