gpt4 book ai didi

java - Camel动态路由器修改消息不起作用

转载 作者:行者123 更新时间:2023-12-01 08:56:11 32 4
gpt4 key购买 nike

Spring 配置:

<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="kafka:127.0.0.1:9092?topic=test1&amp;zookeeperHost=127.0.0.1&amp;zookeeperPort=2181&amp;groupId=group1&amp;serializerClass=kafka.serializer.StringEncoder"/>
<dynamicRouter>
<!-- use a method call on a bean as dynamic router -->
<method ref="compositorSlip" method="slip"/>
</dynamicRouter>
</route>
</camelContext>
<bean id="compositorSlip" class="com.maxent.routingcenter.DynamicRouterTest" />

滑动方法:

public String slip(Exchange exchange, @Header(Exchange.SLIP_ENDPOINT) String previous) {
// just route one time, return null means to end.
if(previous != null){
return null;
}
// I've tried two ways to modify the message body, but they both didn't work.
exchange.getOut().setBody("message modified!!!!!", String.class);
exchange.getIn().setBody("message modified!!!!!", String.class);
if (i++ % 2 == 0) {
return "file://test";
}
return null;
}

我尝试了两种方法来修改邮件正文,但都不起作用。如何修改邮件正文?使用处理器?

最佳答案

您无法修改动态路由器(单条)中的消息。您需要使用消息转换 EIP 来执行此操作,例如调用 bean/处理器等。

关于java - Camel动态路由器修改消息不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42026370/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com