gpt4 book ai didi

java - Camel 'OUT' 消息未从处理器中的 'IN' 填充

转载 作者:行者123 更新时间:2023-11-29 05:13:39 25 4
gpt4 key购买 nike

试图弄清楚如何在处理器中将正文从我的 IN 消息传播到我的 OUT。见下文。请注意,我正在使用流缓存并且我的原始输入是一个流。

public void process(Exchange exchange) throws Exception {

log.debug("In msg:" + exchange.getIn().getBody(String.class));
log.debug("Out msg:" + exchange.getOut().getBody(String.class));

exchange.setOut(exchange.getIn());

log.debug("In msg:" + exchange.getIn().getBody(String.class));
log.debug("Out msg:" + exchange.getOut().getBody(String.class));
}

输出是:

In msg: "My Payload"
Out msg: null
In msg: (empty string)
Out msg: (empty string)

我期望的是:

In msg: "My Payload"
Out msg: null
In msg: "My Payload"
Out msg: "My Payload"

那个空字符串是从哪里来的?

最佳答案

根据引用 docs 的 Claus 评论:

Consider using getIn() As shown above you most often need to alter the existing IN message, than creating a totally new OUT message. And therefore it's often easier just to adjust the IN message directly.

关于java - Camel 'OUT' 消息未从处理器中的 'IN' 填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27390209/

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