Timeout configuration in rabbitmq-jms

98 views
Skip to first unread message

rabbitmqjmsuser

unread,
Nov 18, 2024, 10:01:42 AM11/18/24
to rabbitmq-users
I am using rabbitmq-jms. Sometimes the connection attempt fails with a connection timeout.   
RMQConnectionFactory which I am using doesn't have any method to set the connection timeout.
Could someone let me know how to set the connection timeout?

com.rabbitmq.jms.util.RMQJMSException: Timed out establishing RabbitMQ Connection

        at com.rabbitmq.jms.admin.RMQConnectionFactory.instantiateNodeConnection(RMQConnectionFactory.java:321)

        at com.rabbitmq.jms.admin.RMQConnectionFactory.createConnection(RMQConnectionFactory.java:265)

        at com.rabbitmq.jms.admin.RMQConnectionFactory.createConnection(RMQConnectionFactory.java:231)

        at com.rabbitmq.jms.admin.RMQConnectionFactory.createConnection(RMQConnectionFactory.java:218)

        at com.rabbitmq.jms.admin.RMQConnectionFactory.createTopicConnection(RMQConnectionFactory.java:655)

Arnaud Cogoluègnes

unread,
Nov 19, 2024, 2:52:25 AM11/19/24
to rabbitmq-users
There is the RMQConnectionFactory#setAmqpConnectionFactoryPostProcessor(Consumer<ConnectionFactory>) callback to customize the AMQP 091 ConnectionFactory. Then use ConnectionFactory#setConnectionTimeout(int) (in milliseconds).

rabbitmqjmsuser

unread,
Nov 21, 2024, 4:48:36 AM11/21/24
to rabbitmq-users
Thanks a lot for the pointer. But RMQConnectionFactory doesnt seem to have a method to access the underlying amqconnectionfactory. ( Where we can set the connection timeout)
I have something like this.
RMQConnectionFactory factory = new RMQConnectionFactory();
factory.setHost(), setUser() etc etc.
In order to do a factory. setAmqpConnectionFactoryPostProcessor, I need to get amqconnectionfactory. How do I do it? ( I dont think we should do a new of amqconnectionfactory here)
Thanks

Arnaud Cogoluègnes

unread,
Nov 21, 2024, 8:57:46 AM11/21/24
to rabbitmq-users
The post-processor is a callback: pass your own implementation of Consumer<ConnectionFactory> and it will be called before a connection is created. The callback argument is the connection factory instance, you can call the methods you need there.

Ganesh Udupa

unread,
Nov 30, 2024, 5:12:49 AM11/30/24
to rabbitm...@googlegroups.com
Thanks a lot. That worked

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/rabbitmq-users/6e75365a-3cd7-46a3-89d5-59cfba32f9c5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages