Apache camel Camel:按URL模式的POST请求路由
我试图捕捉一些POST请求,记录一条消息,将来可能还有一个body或params;然后将它们进一步传递给booHost,这样客户端将获得调用的结果:Apache camel Camel:按URL模式的POST请求路由,apache-camel,Apache Camel,我试图捕捉一些POST请求,记录一条消息,将来可能还有一个body或params;然后将它们进一步传递给booHost,这样客户端将获得调用的结果: from("restlet:http://localhost:8090/api/endpointFoo?restletMethod=post") .log("oh, it's a message!") .routeId("someAPI") .to("http://bo
from("restlet:http://localhost:8090/api/endpointFoo?restletMethod=post")
.log("oh, it's a message!")
.routeId("someAPI")
.to("http://booHost:8090/api/endpointFoo?bridgeEndpoint=true&restletMethod=post");
那太好了
但是:
我需要的是这样工作的URL模式。我正在努力:
from("restlet:http://localhost:8090/api/{endpoint}?restletMethod=post")
.log("oh, it's a message!")
.routeId("someAPI")
.to("http://booHost:8090/api/{endpoint}?bridgeEndpoint=true&restletMethod=post");
当我在门柱上投篮的时候。该消息已被记录
但是to似乎没有把{endpoint}当作一个参数——它把它当作一个常量;因此,该调用的结果失败
我不需要硬编码的端点,因为booHost API将来应该在不进行任何更改的情况下进行扩展
换句话说,我需要在同一个端点上捕获所有对*的调用并重新发送给*
也许我应该使用另一个组件?或者我怎样才能做到这一点
谢谢。谢谢@vikingsteve,我已经开始阅读关于recipientList的内容 我已经根据 最终版本如下所示:
from("restlet:http://localhost:8090/api/{endpoint}?restletMethod=post")
.log(LoggingLevel.INFO, "POST-request to /${headers.endpoint} was sent")
.routeId("someAPI")
.recipientList(simple("http://booHost:8090/api/${headers.endpoint}?bridgeEndpoint=true&restletMethod=post"));
它按照建议工作