我在Docker网络中有两个Apache Camel路由器。
一个人充当客户端,并通过路由将体内的一些数据发送到外部。
我现在想从服务器路由器获取修改后的主体。
但是很明显,从未应用过车身修改。
(在上下文中,初始请求是一个发布请求,最终的主体应该是响应)
这是我的“客户”路线的样子:
<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>
“服务器”的外观如下:
<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>
更新:如果我在“客户端”上添加第二条路由,然后将此路由命名为“服务器”的外部,然后修改正在运行的主体
答案 0 :(得分:1)
由于注释而更新:如果setBody
没问题,那么我必须询问代码中的流程。
/finData
,以将请求从客户端发送到服务器? aclient://otherClient:9191
?这条路线不在您的问题之内。 aserver://0.0.0.0:9191
的呼叫者也不在您的问题中。 您可以发布整个流程吗?
原始答案
我认为@ tadayoshi-sato已经评论了您的问题的解决方案。
您使用Camel Simple language(一种表达语言)在您的消息正文中设置一个常量字符串。
<setBody>
<constant>{"result": true }</constant>
</setBody>