![](/img/trans.png)
[英]Setup Apache Camel Rest route using Java DSL on Wildfly Swarm
[英]route url to external rest conroller using apache camel
有沒有辦法將所有請求路由到特定 URI 到另一個項目 rest controller? 考慮下面的代碼:
@Component
public class CamelSportsRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.auto);
rest().path("/hello").get().route()
.toD("localhost:9080/hello");
}
}
我想將/hello
的所有請求路由到另一個項目 rest controller 端點: localhost:9080/hello
但沒有 XML 這是不可能的。
請參閱 jetty 和 undertown 組件的 matchOnUriPrefix 以及 HTTP 組件的 bridgeEndpoint 選項。
這就是你需要的:
from("undertow:http://localhost:8080/hello?matchOnUriPrefix=true")
.to("http4://localhost:8081/hello?bridgeEndpoint=true");
另請參閱this another answer to more details https://stackoverflow.com/a/67893371/11052487
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.