首页 文章

Camel Http4 2.12.2:无法从endpointUri推断出“httpClientConfigurer”

提问于
浏览
0

我正在使用带有http4组件的scala akka-camel(2.12.2版本) . 我正在创建一个带 endpoints 的Camel 生产环境 者:

def endpointUri = "https4://host-path" + 
     "?bridgeEndpoint=true" +
     "&httpClientConfigurer=#configurer" + 
     "&clientConnectionManager=#manager"

其中 configurer 是在Camel上下文注册表中注册的 HttpClientConfigurer (同样的原则适用于 manager ) .

当我将CamelMessage发送到该 endpoints 时,我可以在akka上看到日志:

DEBUG o.a.c.component.http4.HttpComponent - Creating endpoint uri https4://host-path?bridgeEndpoint=true&httpClientConfigurer=#configurer&clientConnectionManager=#manager
DEBUG o.a.camel.util.IntrospectionSupport - Configured property: clientConnectionManager on bean: Endpoint["https4://host-path?bridgeEndpoint=true&httpClientConfigurer=#configurer&clientConnectionManager=#manager"] with value: org.apache.http.impl.conn.PoolingClientConnectionManager@3da3d36f
DEBUG o.a.camel.util.IntrospectionSupport - Configured property: bridgeEndpoint on bean: Endpoint["https4://host-path?bridgeEndpoint=true&httpClientConfigurer=#configurer&clientConnectionManager=#manager"] with value: true
INFO  o.a.c.component.http4.HttpComponent - Registering SSL scheme https on port 443
INFO  o.a.c.component.http4.HttpComponent - Registering SSL scheme https4 on port 443

所以httpClientConfigurer没有配置,我不知道它为什么忽略这个参数 . 我一直在寻找Apache Camel问题跟踪器的任何相关问题,但我发现没有类似的东西 .

任何的想法?提前致谢 .

2 回答

  • 1

    最后,'s resolved. I haven' t使用了 clientConnectionManagerhttpClientConfigurer 中的任何一个 . 我使用了 SSLContextParams 和一个名为TlsConfigurer的特性,它意味着与Producer混合使用 .

    我想使用不同的X509证书,因此,正如Camel建议的那样:

    重要提示:每个HttpComponent只支持一个org.apache.camel.util.jsse.SSLContextParameters实例 . 如果需要使用2个或更多不同的实例,则需要为每个实例定义一个新的HttpComponent .

    因此,TlsConfigurer configure 方法必须能够从camel上下文获取 http4 组件实例,然后应用SSLContextParams并将修改后的实例作为新组件添加到camel上下文 .

    这是它的样子:

    import org.apache.camel.component.http4.HttpComponent
    import org.apache.camel.util.jsse._
    
    trait TlsConfigurer { 
        self: {val camel: akka.camel.Camel} =>
    
        def configure(
            componentName: String, 
            keyStorePath:String, 
            trustStorePath:String, 
            password: String) {
    
            val ksp = new KeyStoreParameters
            ksp.setResource(keystorePath)
            ksp.setPassword(password)
    
            val kmp = new KeyManagersParameters
            kmp.setKeyStore(ksp)
            kmp.setKeyPassword(password)
    
            val scp = new SSLContextParameters
            scp.setKeyManagers(kmp)
    
            val httpComponent = 
               camel.context.getComponent("http4",classOf[HttpComponent])
            httpComponent.setSslContextParameters(scp)
    
            camel.context.addComponent(componentName, httpComponent) 
    
        }
    
    }
    

    这样我就可以创建两个不同的 endpoints : http-client1://...http-client2://... 并以单独的方式管理它们的证书 .

  • 0

    使用IntrospectionSupport未将httpClientConfigurer设置为HttpEndpoint,因此您看不到调试日志 . 我想我们要知道在客户配置器中添加一些日志时会调用configurer .

相关问题