问题描述
我是Apache Camel的新手,我想集成或合并2个API GET请求的结果并将其响应路由到第3个API。
第一个API-http:// localhost:8080 / students / Student1(GET方法返回{“ id”:“ 1”,“ name”:xyz“})
第二个API-http:// localhost:8081 / students / Student1(GET方法返回{“ id”:“ 1”,“ subject”:“ maths”})
第3个API-http:// localhost:8082 / students / combine(GET方法应产生
{“ id”:“ 1”,“主题”:“数学”,“名称”:“ xyz”}
我实际上要执行的操作是使用GET请求访问第三个API,以便它可以隐式调用API1和API2并以以下形式返回输出: {“ id”:“ 1”,“ subject”:“ maths”,“ name”:“ xyz”}
这是我编写的代码。
CamelContext context =新的DefaultCamelContext(); JacksonDataFormat jsonDataFormat =新的JacksonDataFormat(Output.class);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jetty:http://localhost:8080/students/Student1")
.to("direct:merge)
from("jetty:http://localhost:8081/students/Student1")
.to("direct:merge")
from("direct:merge")
.to("jetty:http://localhost:8082/students/combine")
}
});
context.start();
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)