【问题标题】:Creating routes on Camel using domains使用域在 Camel 上创建路由
【发布时间】:2015-10-28 16:34:00
【问题描述】:

我正在运行一个 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");

非常感谢。

【问题讨论】:

    标签: java apache-camel esb


    【解决方案1】:

    您可以像这样创建基于内容的路由器 (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(...);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-11
      • 2019-11-28
      • 1970-01-01
      • 2016-09-14
      • 2011-02-09
      • 2019-05-06
      • 1970-01-01
      相关资源
      最近更新 更多