Announcement Announcement Module
Collapse
No announcement yet.
FatalListenerStartupException - Cannot prepare queue for listener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FatalListenerStartupException - Cannot prepare queue for listener

    Hi all,

    I have following situation. RabbitMQ is used by two systems: system1 and system2. Neither of them is a master system and each of them create own exchanges and queues. See attachment. The problem is when exchanges and queues are not yet configured (first start, or rabbitmq restart) and either system1 or system2 starts. Then I get following exception for listener:

    Code:
    Caused by AmqpIllegalStateException: Fatal exception on listener startup
    Caused by FatalListenerStartupException: Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.
    Caused by IOException: null
    Caused by ShutdownSignalException
    and the system goes down.

    Is there possibility, that listener automatically reconnect to queue even if it does not exist before and such situation does not cause system shutdown? Or maybe there is something wrong in such architecture?

    Best regards
    Tomasz Lempart

  • #2
    If you add a RabbitAdmin to your configuration, the queues, bindings etc will be automatically created during initialization (if needed).

    http://static.springsource.org/sprin...eference/html/

    For example - from the Spring Integration amqp sample app...

    Code:
        <rabbit:connection-factory id="connectionFactory" />
    
        <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
    
        <rabbit:admin connection-factory="connectionFactory" />
    
        <rabbit:queue name="si.test.queue" />
        
        <rabbit:direct-exchange name="si.test.exchange">
            <rabbit:bindings>
                <rabbit:binding queue="si.test.queue" key="si.test.binding" />
            </rabbit:bindings>
        </rabbit:direct-exchange>

    Comment


    • #3
      Originally posted by Gary Russell View Post
      If you add a RabbitAdmin to your configuration, the queues, bindings etc will be automatically created during initialization (if needed).
      I know it and both systems use rabbitAdmin to create own exchanges and queues. System1 creates system1.exchange and system1.queue and System2 creates system2.exchange and system2.queue. But what when only Sytem1 is up and system2.queue does not exist (System1 has no permission to create system2.queue and this is desired)?

      Best regards
      Tomasz Lempart

      Comment


      • #4
        OK; understood. We have an open JIRA to improve connection retries in the listener container https://jira.springsource.org/browse/AMQP-259

        In the meantime, the work around is to not auto-start the container (set autoStart="false" so that the failure to connect doesn't prevent the application context from initializing), and using your own code to start it; something like...

        Code:
        SimpleMessageListenerContainer container = context.getBean(SimpleMessageListenerContainer.class);
        while(!container.isActive()) {
        	try {
        		container.start();
        	}
        	catch (Exception e) {
        		e.printStackTrace();
        	}
        	Thread.sleep(5000);
        }
        I just tested this and it works fine.

        Comment

        Working...
        X