Results 1 to 4 of 4

Thread: FatalListenerStartupException - Cannot prepare queue for listener

  1. #1
    Join Date
    Jul 2005
    Posts
    3

    Default 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
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    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>
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Jul 2005
    Posts
    3

    Default

    Quote 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

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    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.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •