Friends and colleagues,

I have been tasked to implement a message route from an external RabbitMQ 
provider into our Camel-ActiveMQ message service. I am having some difficulties 
getting the rabbit part set up and working within Camel. I get the feeling I am 
close, which may just be an illusion - but I am currently stuck and would 
appreciate any insight more experienced Camel and Rabbit users could provide.

At the moment I am suffering a ConnectionException for a refused connection. 
It's unclear to me whether there are credentials that need to be passed 
somewhere and if so where they are supposed to be defined. In the JMS section 
we're using a truststore as you can see in the listings below. Is the same 
required for the rabbit and if so how/where is that to be configured?

FWIW: We are using camel v2.15.5  and camel-rabbitmq v2.15.6

Here's the error I am currently seeing:
2016-07-20 16:07:17,988 [Camel (camel-1) thread #3 - RabbitMQConsumer] INFO  
org.apache.camel.component.rabbitmq.RabbitMQConsumer - Connection failed, will 
retry in {}100ms
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at 
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at 
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at 
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at 
com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
    at 
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:811)
    at 
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:767)
    at 
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:887)
    at 
org.apache.camel.component.rabbitmq.RabbitMQEndpoint.connect(RabbitMQEndpoint.java:195)
    at 
org.apache.camel.component.rabbitmq.RabbitMQConsumer.openConnection(RabbitMQConsumer.java:68)
    at 
org.apache.camel.component.rabbitmq.RabbitMQConsumer.access$500(RabbitMQConsumer.java:36)
    at 
org.apache.camel.component.rabbitmq.RabbitMQConsumer$StartConsumerCallable.call(RabbitMQConsumer.java:323)
    at 
org.apache.camel.component.rabbitmq.RabbitMQConsumer$StartConsumerCallable.call(RabbitMQConsumer.java:304)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

And what  I think are the relevant parts of the configuration...

<!-These are commented out at present but were tried with similar results 
earlier
    <route id="rabbit_route">
        <from uri="rabbitmq://localhost:5672/rabbit?sslProtocol=true"/>
        <to uri="{{data_dir}}/?fileName=rabbitMessage" />
    </route>
    <route id="rabbit_route">
        <from 
uri="rabbitmq://localhost:5672/rabbit?connectionFactory=#rabbitConnectionFactory"/>
        <to uri="{{data_dir}}/?fileName=rabbitMessage" />
    </route>
-->

   <route id="rabbit_route">
       <from uri="rabbitmq://localhost:5672/rabbit"/>
       <to uri="{{data_dir}}/?fileName=rabbitMessage" />
   </route>
...
<!--- JMS/Rabbit beans.... --->
<!-- ############################ Local JMS Configuration  
##################### -->
<bean id="localConnFactory" 
class="org.apache.activemq.ActiveMQSslConnectionFactory">
    <property name="trustAllPackages" value="true" />
    <property name="brokerURL" value="${local.broker.url}" />
    <property name="trustStore" value="${local.truststore.file}" />
    <property name="trustStorePassword" value="${local.truststore.password}" />
</bean>
<bean id="localPooledConnFactory" 
class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" 
destroy-method="stop">
    <property name="connectionFactory" ref="localConnFactory" />
    <property name="maxConnections" value="${local.max.conn}" />
    <property name="idleTimeout" value="${local.idle.timeout}" />
</bean>
<bean id="localConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="localPooledConnFactory" />
    <property name="transacted" value="false" />
</bean>
<bean id="localJms" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="localConfig" />
</bean>

<bean id="rabbitmq" 
class="org.apache.camel.component.rabbitmq.RabbitMQComponent">
</bean>

>From the logs...

...
2016-07-20 16:22:37,603 [main] DEBUG 
org.springframework.context.support.FileSystemXmlApplicationContext - Bean 
factory for 
org.springframework.context.support.FileSystemXmlApplicationContext@48524010: 
org.springframework.beans.factory.support.DefaultListableBeanFactory@73c60324: 
defining beans 
[org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,bridgePropertyPlaceholder,audit_log,producerTemplate,org.apache.camel.spring.CamelRedeliveryPolicyFactoryBean#0,defaultEH,consumerTemplate,camel-1:beanPostProcessor,camel-1,broadcastProcessor,fileWrapper,timeUtil,...,redeliveryPolicyConfig,localConnFactory,localPooledConnFactory,localConfig,localJms,rabbitmq];
 root of factory hierarchy
...
2016-07-20 16:22:37,756 [main] INFO  
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Pre-instantiating singletons in 
org.springframework.beans.factory.support.DefaultListableBeanFactory@73c60324: 
defining beans 
[org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,bridgePropertyPlaceholder,audit_log,producerTemplate,org.apache.camel.spring.CamelRedeliveryPolicyFactoryBean#0,defaultEH,consumerTemplate,camel-1:beanPostProcessor,camel-1,broadcastProcessor,fileWrapper,timeUtil,...,redeliveryPolicyConfig,localConnFactory,localPooledConnFactory,localConfig,localJms,rabbitmq,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];
 root of factory hierarchy
...
2016-07-20 16:22:39,278 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - 
instantiating session factory with properties: {java.vendor=Oracle Corporation, 
sun.java.launcher=SUN_STANDARD, javax.net.ssl.trustStorePassword=paXXXXrd, 
sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.name=Linux, 
sun.boot.class.path=/apps/java/jre1.8.0_60/lib/resources.jar:/apps/java/jre1.8.0_60/lib/rt.jar:/apps/java/jre1.8.0_60/lib/sunrsasign.jar:...
 java.specification.version=1.8, 
javax.net.ssl.trustStore=/apps/configs/keys/client.ts, hibernate.show_sql=false}
...
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished 
creating instance of bean 'localPooledConnFactory'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
shared instance of singleton bean 'localConfig'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
instance of bean 'localConfig'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly 
caching bean 'localConfig' to allow for resolving potential circular references
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Returning cached instance of singleton bean 'localPooledConnFactory'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished 
creating instance of bean 'localConfig'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
shared instance of singleton bean 'localJms'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
instance of bean 'localJms'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly 
caching bean 'localJms' to allow for resolving potential circular references
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Returning cached instance of singleton bean 'localConfig'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished 
creating instance of bean 'localJms'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
shared instance of singleton bean 'rabbitmq'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
instance of bean 'rabbitmq'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly 
caching bean 'rabbitmq' to allow for resolving potential circular references
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished 
creating instance of bean 'rabbitmq'
...
[main] DEBUG org.apache.camel.core.xml.AbstractCamelContextFactoryBean - Found 
JAXB created routes: 
[...Route(rabbit_route)[[From[rabbitmq://localhost:5672/rabbit]] -> 
[To[{{data_dir}}/?fileName=rabbitMessage]]],...
...
[main] DEBUG org.apache.camel.impl.DefaultComponentResolver - Found component: 
rabbitmq in registry: 
org.apache.camel.component.rabbitmq.RabbitMQComponent@6dcbbb49
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=components,name="rabbitmq"
[main] DEBUG org.apache.camel.impl.DefaultComponent - Creating endpoint 
uri=[rabbitmq://localhost:5672/rabbit], path=[localhost:5672/rabbit]
[main] DEBUG org.apache.camel.component.rabbitmq.RabbitMQComponent - Creating 
RabbitMQEndpoint with host localhost:5672 and exchangeName: rabbit
[main] DEBUG org.apache.camel.spring.SpringCamelContext - 
rabbitmq://localhost:5672/rabbit converted to endpoint: 
Endpoint[rabbitmq://localhost:5672/rabbit] by component: 
org.apache.camel.component.rabbitmq.RabbitMQComponent@6dcbbb49
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=endpoints,name="rabbitmq://localhost:5672/rabbit"
[main] DEBUG org.apache.camel.component.properties.PropertiesComponent - Parsed 
location: ref:bridgePropertyPlaceholder
[main] DEBUG org.apache.camel.component.properties.DefaultPropertiesParser - 
Found property: data_dir with value: file:///apps/data to be used.
[main] DEBUG org.apache.camel.spring.SpringCamelContext - Resolved text: 
{{data_dir}}/?fileName=rabbitMessage -> 
file:///apps/data/?fileName=rabbitMessage
[main] DEBUG org.apache.camel.util.IntrospectionSupport - Configured property: 
uri on bean: To[file:///apps/data/?fileName=rabbitMessage] with value: 
file:///apps/data/?fileName=rabbitMessage
[main] DEBUG org.apache.camel.model.ProcessorDefinitionHelper - Changed 
property [uri] from: {{data_dir}}/?fileName=rabbitMessage to: 
file:///apps/data/?fileName=rabbitMessage
[main] DEBUG org.apache.camel.impl.DefaultComponent - Creating endpoint 
uri=[file:///apps/data/?fileName=rabbitMessage], path=[/apps/data/]
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating 
instance of bean 'org.apache.camel.language.constant.ConstantLanguage'
[main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished 
creating instance of bean 'org.apache.camel.language.constant.ConstantLanguage'
[main] DEBUG org.apache.camel.util.IntrospectionSupport - Configured property: 
fileName on bean: Endpoint[file:///apps/data/?fileName=rabbitMessage] with 
value: rabbitMessage
[main] DEBUG org.apache.camel.spring.SpringCamelContext - 
file:///apps/data/?fileName=rabbitMessage converted to endpoint: 
Endpoint[file:///apps/data/?fileName=rabbitMessage] by component: 
org.apache.camel.component.file.FileComponent@1c18ee69
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=endpoints,name="file:///apps/data/\?fileName=rabbitMessage"
[main] DEBUG org.apache.camel.processor.interceptor.DefaultChannel - Initialize 
channel for target: 'To[file:///apps/data/?fileName=rabbitMessage]'
...
[main] DEBUG org.apache.camel.spring.SpringCamelContext - Warming up route id: 
rabbit_route having autoStartup=true
[main] DEBUG org.apache.camel.impl.RouteService - Starting services on route: 
rabbit_route
[main] DEBUG org.apache.camel.impl.RouteService - Starting child service on 
route: rabbit_route -> 
Channel[sendTo(Endpoint[file:///apps/data/?fileName=rabbitMessage])]
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=producers,name=GenericFileProducer(0x4fd37449)
[main] DEBUG org.apache.camel.component.file.GenericFileProducer - Starting 
producer: Producer[file:///apps/data/?fileName=rabbitMessage]
[main] DEBUG org.apache.camel.impl.ProducerCache - Adding to producer cache 
with key: Endpoint[file:///apps/data/?fileName=rabbitMessage] for producer: 
Producer[file:///apps/data/?fileName=rabbitMessage]
[main] DEBUG org.apache.camel.processor.DefaultErrorHandler - Redelivery 
enabled: true on error handler: 
DefaultErrorHandler[Instrumentation:to[sendTo(Endpoint[file:///apps/data/?fileName=rabbitMessage])]]
[main] DEBUG org.apache.camel.impl.RouteService - Starting child service on 
route: rabbit_route -> 
sendTo(Endpoint[file:///apps/data/?fileName=rabbitMessage])
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=processors,name="to5"
[main] DEBUG org.apache.camel.impl.RouteService - Starting child service on 
route: rabbit_route -> 
Channel[sendTo(Endpoint[file:///apps/data/?fileName=rabbitMessage])]
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=routes,name="rabbit_route"
...
[main] DEBUG org.apache.commons.httpclient.HttpClient - Java class path: ... 
/apps/activemq/lib/camel/camel-rabbitmq-2.15.6.jar:/apps/activemq/lib/rabbitmq-client.jar
...
[main] DEBUG org.apache.camel.spring.SpringCamelContext - Route: rabbit_route 
>>> EventDrivenConsumerRoute[Endpoint[rabbitmq://localhost:5672/rabbit] -> 
Channel[sendTo(Endpoint[file:///apps/data/?fileName=rabbitMessage])]]
[main] DEBUG org.apache.camel.spring.SpringCamelContext - Starting consumer 
(order: 1003) on route: rabbit_route
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=consumers,name=RabbitMQConsumer(0x241d1052)
[main] DEBUG org.apache.camel.management.DefaultManagementAgent - Registered 
MBean with ObjectName: 
org.apache.camel:context=camel-1,type=threadpools,name="RabbitMQEndpoint(0xc5a2d5)"
[main] DEBUG org.apache.camel.impl.DefaultExecutorServiceManager - Created new 
ThreadPool for source: Endpoint[rabbitmq://localhost:5672/rabbit] with name: 
RabbitMQConsumer. -> 
org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@185339ed[Running, 
pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 
0][RabbitMQConsumer]
[main] DEBUG org.apache.camel.component.rabbitmq.RabbitMQConsumer - Using 
executor 
org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@185339ed[Running, 
pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 
0][RabbitMQConsumer]
[main] INFO  org.apache.camel.component.rabbitmq.RabbitMQConsumer - Connection 
failed, will start background thread to retry!
...
java.net.ConnectException: Connection refused


------------
My status:  I am relatively new to Camel and have interacted with it in 
passing. Very new to RabbitMQ and have only very recent experience with it. 
I've tried to RTFM but found no TFM to read that has been terribly helpful in 
the matter. Could be my searches simply haven't found it, but if so I assume 
it's reasonably well hidden.

Thanks in advance for any assistance.

- j kammer

Reply via email to