【发布时间】:2022-02-18 23:30:13
【问题描述】:
我正在尝试将消息从 REST API 发送到新路由,即使您在我的 REST API 上收到 JSON 格式的请求并且绑定设置为 JSON,当我将其转发到新路由时,它也会显示为 InputStream我必须将它编组为 JSON 才能使用它。
我已经尝试在 RestConfiguration 中使用 streamCaching 和其他组件(consumes、produces、type、dataType)。我也在使用 POM 中的所有依赖项。
public void configure() {
restConfiguration().component("servlet")
.bindingMode(RestBindingMode.json)
.skipBindingOnErrorCode(false);
rest("/resttest")
.patch("/t1")
.id("t1")
.description("t1")
.consumes("application/json")
.produces("application/json")
.param()
.name("body")
.type(RestParamType.body)
.dataType("json")
.required(true)
.endParam()
.to("direct:test2");
这条路线在其他类别中:
from("direct:test2").id("test2")
.marshal().json(JsonLibrary.Jackson,SomePOJO.class)
.unmarshal().json(JsonLibrary.Jackson, SomePOJO.class)
.choice()
.when(simple("${body.getStatus()} =~ 'Closed'"))
.....
我期待在 test2 路由上得到 JSON 消息,但不知何故我得到了 InputStream,所以我必须先进行编组。任何人都知道如何让 REST API 将我转发到 JSON 格式的路由消息,而不是流?
【问题讨论】:
标签: json rest apache-camel spring-camel