Apache camel 驼峰HTTP响应主体为空,但exchange主体具有有效负载

Apache camel 驼峰HTTP响应主体为空,但exchange主体具有有效负载,apache-camel,Apache Camel,转换主体后,如果我打印exchange主体,我会看到有效负载。但是来自rest服务的HTTP响应总是空的 以前有人遇到过这个问题吗?如果是,是否有解决办法?您可能需要在路由中启用流缓存: 它允许为这些流备份组件多次读取正文 rest("/getOptChoice"). get("/v1") .consumes("application/json") .to("direct:hello") .produces("application

转换主体后,如果我打印exchange主体,我会看到有效负载。但是来自rest服务的HTTP响应总是空的


以前有人遇到过这个问题吗?如果是,是否有解决办法?

您可能需要在路由中启用流缓存:

它允许为这些流备份组件多次读取正文

rest("/getOptChoice").
        get("/v1")
        .consumes("application/json")
        .to("direct:hello")
        .produces("application/json");

from("direct:hello")
        .split(header("emails"))
        .to("seda:consumeGuestChoice")
        .aggregate(constant(true),new OptAggregator())
        .completionSize(2)
        .marshal(jaxb)
        .convertBodyTo(String.class);
如果你写:

from("direct:hello")
    .streamCaching()
    .split(header("emails"))
    .to("seda:consumeGuestChoice")
    .aggregate(constant(true),new OptAggregator())
    .completionSize(2)
    .marshal(jaxb)
    .convertBodyTo(String.class);

这可能有用。是吗?

在拆分后,我目前正面临这个问题。你找到什么了吗?
from("direct:hello")
    .split(header("emails"), new OptAggregator())
        .to("seda:consumeGuestChoice")
        .end()
    .marshal(jaxb)
    .convertBodyTo(String.class);