Home Grails(spring-amqp) - connecting with RabbitMQ with SSL through XML configuration
Reply: 1

Grails(spring-amqp) - connecting with RabbitMQ with SSL through XML configuration

L.J.
1#
L.J. Published in 2018-02-06 10:55:32Z

I've been trying to modify configuration of an old project(that is based on grails 2.5.6) to use ssl connection when integrating with RabbitMQ instance. I have spring-amqp in version 1.4.6. My old version of config is written in a xml file like this:

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.4.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<rabbit:connection-factory
        id="connectionFactory"
        username="guest2"
        password="guest"
        virtual-host="dev"
        host="localhost"
        port="5672"
/>

I also have listeners configured like this:

<bean id="rabbitListener" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="queues" ref="rabbitQueue" />
    <property name="defaultRequeueRejected" value="false"/>
    <property name="messageListener" ref="listenerService" />
    <property name="errorHandler" ref="errorHandlerService" />
    <property name="autoStartup" value="false" />
    <property name="concurrentConsumers" value="1" />
</bean>

I've set up rabbitmq server so it has available ssl connection at port 5671. Then based on documentation i've found here: spring-documentation, i've modified xml config like this:

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.4.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<rabbit:connection-factory
        id="connectionFactory"
        connection-factory="clientConnectionFactory"
        username="guest2"
        password="guest"
        virtual-host="dev"
        host="localhost"
        port="5671"
/>

<bean id="clientConnectionFactory"
      class="org.springframework.xd.dirt.integration.rabbit.RabbitConnectionFactoryBean">
    <property name="useSSL" value="true" />
    <property name="sslPropertiesLocation" value="file://./rabbitSSL.properties"/>
</bean>

With that configuration when running application i get errors looking like this:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitListener' defined in URL [file:/target/classes/rabbitmq/resources-listeners.xml]: Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory': Cannot create inner bean '(inner bean)#50b63731' of type [org.springframework.xd.dirt.integration.rabbit.RabbitConnectionFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#50b63731': Invocation of init method failed; nested exception is java.net.UnknownHostException: .

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#50b63731': Invocation of init method failed; nested exception is java.net.UnknownHostException: .

I've been struggling with this issue. I'm not sure how to interpret this error and how to solve it. Has anyone encountered similiar issue or might have a clue what might be wrong with this configuration ?

L.J.
2#
L.J. Reply to 2018-02-12 07:07:55Z

That's a late reply but i've found the issue. It was my fault all along. After debugging i've found that sslPropertiesLocation was set incorrectly. Double / in file://./rabbit.. made it go for incorrect ftp location. After setting proper file location like: file:grails-app/conf/rabbit/file connection got set up. The debug suggestion made me realize my mistake. Thanks a lot.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300862 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO