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

  • RabbitMQ asynchronous consumer connection failover

    Hello!
    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" />

    Thanks!

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

    Comment


    • #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?


      Code:
      <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="amqp.direct" />
      
      <rabbit:queue name="myQueue" durable="true">
      	<rabbit:queue-arguments>
      		<entry key="ha-mode" value="all" />
      	</rabbit:queue-arguments>
      </rabbit:queue>
      
      <rabbit:direct-exchange name="amqp.direct">
      	<rabbit:bindings>
      		<rabbit:binding queue="myQueue" />
      	</rabbit:bindings>
      </rabbit:direct-exchange>
      
      <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" />
      Code:
      WARN: Reconnect failed; retries left=2
      java.io.IOException
      	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
      	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
      	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
      	at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:755)
      	at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:61)
      (...)
      Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=404, reply-text=NOT_FOUND - home node 'rabbit@rabbit1' of durable queue 'myQueue' in vhost '/' is down or inaccessible, class-id=50, method-id=10), null, ""}
      	at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:454)
      	at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:294)
      	at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)
      	at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)
      	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:526)
      (...)
      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.

      Comment


      • #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.

        http://www.rabbitmq.com/blog/2012/11...-rabbitmq-3-0/

        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, 05:53 PM.

        Comment


        • #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 http://www.rabbitmq.com/ha.html;

          Code:
          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.

          Thanks!

          Comment

          Working...
          X