apache-camel rabbitmq ssl集成不起作用

问题描述 投票:0回答:1

我们正在使用apache-camel与Rabbitmq连接。现在,我们计划使用https连接Rabbitmq。我按照步骤使用[

将Rabbitmq启用到https

https://www.rabbitmq.com/ssl.html

现在正在使用我的代码。

rabbitmq://host:port/exchange?autoAck=false&autoDelete=false&password=test&prefetchCount=1&queue=testqueue&sslProtocol=TLSv1.2&username=test

如果我们在rabbimq中禁用对等验证,则效果很好。但是,如果我想启用对等验证,则需要通过KeyManager和truststore。不确定如何传递此详细信息。我可以看到文档说将connectionFactory用作

要使用自定义RabbitMQ连接工厂。设置此选项后,将不使用在URI上设置的所有连接选项(connectionTimeout,requestedChannelMax ...

当我将其作为查询参数的一部分给出时,出现以下错误。

ERROR [2020-01-10 19:29:12,030] io.dropwizard.cli.ServerCommand: Unable to start server, shutting down                                                                                                 
! org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: com.rabbitmq.client.ConnectionFactory@44f0ff2b of type: com.rabbitmq.client.ConnectionFactory                      
! at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:173)                                                                                                             
! at org.apache.camel.util.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:326)                                                                                                           
! at org.apache.camel.util.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:308)                                                                                                           
! at org.apache.camel.impl.DefaultComponent.resolveAndRemoveReferenceParameter(DefaultComponent.java:415)                                                                                              
! at org.apache.camel.impl.DefaultComponent.resolveAndRemoveReferenceParameter(DefaultComponent.java:394)                                                                                              
! at org.apache.camel.component.rabbitmq.RabbitMQComponent.createEndpoint(RabbitMQComponent.java:62)                                                                                                   
! at org.apache.camel.component.rabbitmq.RabbitMQComponent.createEndpoint(RabbitMQComponent.java:32)                                                                                                   
! at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:116)                                                                                                                  
! at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:631)                                                                                                               
! ... 33 common frames omitted                                                                                                                                                                         
! Causing: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: rabbitmq://host:port/exchangeName?autoAck=false&autoDelete=false&connectionFactory=com.rabbitmq.c
lient.ConnectionFactory%4044f0ff2b&password=test&prefetchCount=1&queue=testQueue&sslProtocol=TLSv1.2&username=test due to: No bean could be found in the registry for: com.rabbitmq.client.Connec
tionFactory@44f0ff2b of type: com.rabbitmq.client.ConnectionFactory                                                                                                                                    
! at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:678)                                                                                                               
! at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)                                                                                                         
! at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219)                                                                                                                  
! at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)                                                                                                           
! at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:118)                                                                                                           
! at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)                                                                                                                     
! at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:94)                                                                                                                
! at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1278)                                                                                                                       
! at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204)                                                                                                                        
! ... 25 common frames omitted                                                                                                                                                                         
! Causing: org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[rabbitmq://10.65.226.201:5671/preValidat... because of Failed to resolve endpoint: rabbitmq://host:port/exchangeName?autoAck=false&autoDelete=false&connectionFactory=com.rabbitmq.c
lient.ConnectionFactory%4044f0ff2b&password=test&prefetchCount=1&queue=testQueue&sslProtocol=TLSv1.2&username=test due to: No bean could be found in the registry for: com.rabbitmq.client.ConnectionFactory@44f0ff2b of type: com.rabbitmq.client.ConnectionFactory 

如何将connectionFactory中的rabbitmq传递给uri。

我们正在使用apache-camel与Rabbitmq连接。现在,我们计划使用https连接Rabbitmq。我按照步骤使用https://www.rabbitmq.com/ssl.html启用Rabbitmq到https。现在...

要传递ConnectionFactory对象实例,我们需要查找对象,这可以通过将对象放入注册表,创建注册表并将连接放入注册表来实现。有关详细信息camel & Rabbitmq Custom ConnectionFactory

    SimpleRegistry simpleRegistry = new SimpleRegistry();
    String beanName = "rabbitConnectionFactory";
    simpleRegistry.put(beanName, connectionFactory);
    CamelContext camelContext = new DefaultCamelContext(simpleRegistry);

然后创建将引用connectionFactory的Rabbitmq URL。

"rabbitmq:/jobProgress?autoAck=false&autoDelete=false&prefetchCount=1&prefetchEnabled=true" +
            "&queue=jobProgress&connectionFactory=#rabbitConnectionFactory";
java rabbitmq apache-camel
1个回答
0
投票

要传递ConnectionFactory对象实例,我们需要查找对象,这可以通过将对象放入注册表,创建注册表并将连接放入注册表来实现。有关详细信息camel & Rabbitmq Custom ConnectionFactory

© www.soinside.com 2019 - 2024. All rights reserved.