Talend ESB & RabbitMQ: connecting a listener/consumer to queue

Viewed 330

I am currently trying to build a consumer for a RabbitMQ Queue with Talend open studio for ESB. After reading every post I could find on this topic, I have 2 different versions, but none that actually works.

Version 1:

My Route:

cMessagingEndpoint Route

The cMessagingEndpoint1 URI:

"rabbitmq://host:port/exchange?username=xxxxx&password=xxxx&queue=xxxx"

I have also tried adding durable = true and no_declare = true to this URI, but then I receive an unknow parameter error. So I removed those 2 again.

cMessagingEndpoint URI

cMessagingEndpoint Camel component

The console output: This seems to be old syntax and a driver error is causing the connection to close.

Console Output

[WARN ] 09:29:07 org.apache.camel.component.rabbitmq.RabbitMQComponent- The old syntax rabbitmq://hostname:port/exchangeName is deprecated. You should configure the hostname on the component or ConnectionFactory
[WARN ] 09:29:08 com.rabbitmq.client.impl.ForgivingExceptionHandler- An unexpected connection driver error occured (Exception message: Connection reset)
[WARN ] 09:29:08 org.apache.camel.component.rabbitmq.RabbitConsumer- Unable to open channel for RabbitMQConsumer. Continuing and will try again

I assume the driver error could be caused by me not sending along "durable: true, no_declare: true", but I am not sure where to add those 2 options.

Version 2:

Route 2

My ConnectionFactory

cMQConnectionFactory settings

The actual queue defined.

cAMQ settings

Including durable and no_declare. These have to be defined, or I can never connect to the RabbitMQ Server

cAMQ advanced settings

But again I receive an unknown parameter error.

org.apache.camel.FailedToCreateRouteException: Failed to create route test_receiveMQMessage_cAMQP_1: Route(test_receiveMQMessage_cAMQP_1)[[From[cMQConnectionFact... because of Failed to resolve endpoint: cMQConnectionFactory1://queue:arcplace?durable=true&no_declare=true due to: Failed to resolve endpoint: cMQConnectionFactory1://queue:arcplace?durable=true&no_declare=true due to: There are 2 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{durable=true, no_declare=true}]

Does someone have an idea how I can fix this problem and connect my listener to the RabbitMQ queue?

Thanks

Edit:

To test and make sure a connection is even possible, I created a ruby script to publishe messages to an exchange and to consume messages sent to the queue. That works without any problems.

I am still trying to get the Talend Route / Job to work.

Edit 2:

I checked the settings of the RabbitMQ Broker. It is bare-bones installation, supporting AMQP 0.9.1 over TLS. AMQP 1.0 or MQTT are not supported.

1 Answers

To continue using AMQP 0.9, you have to use cMessagingEndpoint with a rabbitmq url (new syntax with a connection factory bean) :

rabbitmq:myexchange?queue=myqueue

You have to register a connection factory bean that camel will detect automatically with a cBeanRegister. I use a global bean instance to pass context variables like host, user, etc. cBeanRegister is configured in simple mode with class name beans.RabbitConnectionFactory and with a single argument "context" (it's your properties context). You can specify bean id as you want.

public class RabbitConnectionFactory extends ConnectionFactory {

    public RabbitConnectionFactory(Properties properties) {
        setHost(properties.getProperty("amqp_host"));
        setPort(Integer.parseInt(properties.getProperty("amqp_port")));
        setUsername(properties.getProperty("amqp_user"));
        setPassword(properties.getProperty("amqp_password"));
    }
}
Related