我正在运行Apache Camel的一个实例,以便将请求代理到另一个服务器(取决于URI)。Camel服务器正在通过许多不同的域(例如app1.server.com、app2.server.com)进行响应。
通过使用jetty和http4,我能够通过执行以下操作代理请求:
from("jetty://http://app.server.com:8080/app1?matchOnUriPrefix=true").to("http4://app1host:8080?bridgeEndpoint=true&throwExceptionOnFailure=false");
from("jetty://http://app.server.com:8080/app2?matchOnUriPrefix=true").to("http4://app2host:8080?bridgeEndpoint=true&throwExceptionOnFailure=false");有没有办法可以根据域名创建路由?如下所示:
from("jetty://http://app1.server.com:8080?matchOnUriPrefix=true").to("http4://app1host:8080?bridgeEndpoint=true&throwExceptionOnFailure=false");
from("jetty://http://app2.server.com:8080?matchOnUriPrefix=true").to("http4://app2host:8080?bridgeEndpoint=true&throwExceptionOnFailure=false");非常感谢。
发布于 2015-08-30 00:48:43
您可以像这样创建基于内容的路由器(http://camel.apache.org/content-based-router.html)
from("jetty://http://0.0.0.0:8080")
.choice()
.when(header("host").contains("app1.server.com"))
.log("app1.server.com").to(...)
.when(header("host").contains("app2.server.com"))
.log("app2.server.com").to(...);https://stackoverflow.com/questions/31840320
复制相似问题