Announcement Announcement Module
No announcement yet.
RabbitMQ asynchronous consumer connection failover Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RabbitMQ asynchronous consumer connection failover

    Anyone knows where I can find an Spring Integration context configuration for connection failover using two RabbitMQ hosts?

    <rabbit:connection-factory id="connectionFactory" addresses="a1-judas-s-prt1:5672,a1-judas-s-prt2:5672" />


  • #2
    That is correct - why do you need an example?


    • #3
      Because reconnection is not working.

      Scenario: I start my subscriber with both judas1 and judas2 rabbits up. Then I shutdown rabbit on judas1, a ShutdownSignalException is raised and after some retries the integration channel goes down.

      What I'd expect is a switch to the judas2. What's missing?

      <rabbit:connection-factory id="connectionFactory" addresses="a1-judas-s-prt1:5672,a1-judas-s-prt2:5672" />
      <rabbit:admin connection-factory="connectionFactory" />
      <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" exchange="" />
      <rabbit:queue name="myQueue" durable="true">
      		<entry key="ha-mode" value="all" />
      <rabbit:direct-exchange name="">
      		<rabbit:binding queue="myQueue" />
      <int:channel id="fromRabbit" />
      <int-amqp:inbound-channel-adapter channel="fromRabbit" queue-names="myQueue" connection-factory="connectionFactory" />
      <int:service-activator input-channel="fromRabbit" ref="service" method="execute" />
      WARN: Reconnect failed; retries left=2
      	at com.rabbitmq.client.impl.AMQChannel.wrap(
      	at com.rabbitmq.client.impl.AMQChannel.wrap(
      	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(
      	at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(
      	at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(
      Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=404, reply-text=NOT_FOUND - home node '[email protected]' of durable queue 'myQueue' in vhost '/' is down or inaccessible, class-id=50, method-id=10), null, ""}
      	at com.rabbitmq.client.impl.ChannelN.asyncShutdown(
      	at com.rabbitmq.client.impl.ChannelN.processAsync(
      	at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(
      	at com.rabbitmq.client.impl.AMQChannel.handleFrame(
      	at com.rabbitmq.client.impl.AMQConnection$
      INFO: Stopping container from aborted consumer
      16/04/2013 17:31:28 org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer doShutdown
      INFO: Waiting for workers to finish.
      16/04/2013 17:31:28 org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer doShutdown
      INFO: Successfully waited for workers to finish.


      • #4
        Your HA config doesn't look right. What version of RabbitMQ are you using? Prior to 3.0.x, the argument was "x-ha-policy=all" (you have "ha-mode").

        The HA is no longer managed with a queue argument in 3.0.x, it's configured on the broker with rabbitmqctl (using ha-mode). So it looks like you are mixing 2.x and 3.x configuration concepts.

        Just to be clear, it looks like we are connecting OK, but then rabbit is rejecting the queueDeclarePassive call because it can't find the home node for the queue.
        Last edited by Gary Russell; Apr 16th, 2013, 04:53 PM.


        • #5
          Thanks Garry! The failover worked like a charm!

          I removed the legacy rabbit 2.x configuration ha-mode parameter from my queue on Spring context;

          Added a policy on Rabbit so that all queues created with "ha." on their name contains the ha-mode: all configuration, following the example on;

          rabbitmqctl set_policy ha-all "^ha\." '{"ha-mode":"all"}'
          Changed my queue name to ha.queue;

          Then Spring Integration reactivate the channels on Rabbit crashes, even firewall blocks.