Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any option to set AutomaticRecoveryEnabled in RabbitMQ using Spring-AMQP?

Getting stocked while doing with RabbitMQ using Spring-AMQP.

Just need to get a way to configure AutomaticRecoveryEnabled and NetworkRecoveryInterval using Spring-AMQP. There is a direct option to set these flages if you you developing using native RabbitMQ library. But i didn't find a workaround to do the same using spring

Using RabbitMQ Native library(don't need any help)

factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(10000);

Using Spring-AMPQ(need help)

Like above i didn't find any such method while trying with Spring-AMPQ. This is what i am doing now.

@Bean(name="listener")
public SimpleMessageListenerContainer listenerContainer() 
{
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory());
    container.setQueueNames(env.getProperty("mb.queue"));
    container.setMessageListener(new MessageListenerAdapter(messageListener));
    return container;
}

Any help in this regards is highly appreciable. Thanks in advance.

like image 852
lambodar Avatar asked Feb 13 '23 07:02

lambodar


1 Answers

Just to clarify; Spring AMQP is NOT compatible with automaticRecoveryEnabled.

It has its own recovery mechanisms and has no awareness of the underlying recovery being performed by the client. This leaves dangling connection(s) and Channel(s).

I am working on a temporary work-around that will make it compatible (but will effectively disable the client recovery of any connections/channels used by Spring AMQP, while leaving the client recovery in place for other users of the same connection factory.

A longer term fix will require a major rewrite of the listener container to utilize the client recovery code instead.

like image 84
Gary Russell Avatar answered Feb 15 '23 07:02

Gary Russell