I need to consume messages from Rabbit HA cluster via HAProxy so I switched to CacheMode.CONNECTION
as it is recommended in spring-amqp-documentation. Moreover I need to consume messages from many queues so I create for each queue SimpleMessageListenerContainer
with 4 concurrent consumers and I have few questions:
SimpleMessageListenerContainer
what looks more efficient but maybe there is another better way?CacheMode.CONNECTION
for each consumer in SimpleMessageListenerContainer
is created new connection? Can I set in some way one connection for all consumers in a given SimpleMessageListenerContainer
or maybe it is not recommended?How to handle exception
"org.springframework.amqp.rabbit.connection.AutoRecoverConnectionNotCurrentlyOpenException: Auto recovery connection is not currently open"
I received it when one RabbitMQ node is down. Even when node is up again SimpleMessageListenerContainer
cannot reconnect.
Thanks in advance for help.
The upcoming 2.0 release has a new DirectMessageListenerContainer
that shares threads across containers documentation here.
The 2.0.0.M4
milestone is available now; the GA release is expected to be mid July.
If you want a single connection per container use the default cache mode and a separate connection factory for each container.
Disable the client's connection factory auto recovery mechanism; it is enabled by default in the 4.x client; Spring AMQP has its own recovery mechanism that will generally recover faster. Since version 1.7.1 Spring AMQP disables it by default, unless you configure your own Rabbit ConnectionFactory.