Farhan
Farhan

Reputation: 431

RabbitMQ - no queue found stopping Spring server

I have a spring application which is consuming messages from rabbitmq. However, the spring server fails to start when the RabbitMQ server is down.

Below is the exception,

Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - vhost test_queue not found, class-id=10, method-id=40)
        at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:366) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:381) ~[amqp-client-4.0.1.jar:4.0.1]
        at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62) ~[amqp-client-4.0.1.jar:4.0.1]

Is there a way to still have the spring application start even when no queue is found?

Spring configuration.

<rabbit:connection-factory id="connectionFactory" host="${host}" port="${port}" username="${rabbitmq.username}" password="${rabbitmq.password}" virtual-host="${rabbitmq.virtualhost}"/>

    <rabbit:queue name="${rabbitmq.create.queue}" />


    <rabbit:template queue="${rabbitmq.feedback.queue}"
    exchange="${rabbitmq.feedback.exchange}" id="amqpTemplate"
    connection-factory="connectionFactory" />

    <bean id="xyzConsumerListener" class="com.sample.rabbitmq.listener.XyzConsumerListener">
    </bean>

    <rabbit:listener-container id="myListenerContainer" connection-factory="connectionFactory">
        <rabbit:listener ref="xyzConsumerListener" queue-names="${rabbitmq.create.queue}"/>
    </rabbit:listener-container>

Regards, Farhan

Upvotes: 5

Views: 6921

Answers (1)

Dave G
Dave G

Reputation: 9767

The error message states that it is unable to find the vhost named test_queue.

Please check that the vhost exists or use / as your vhost.

In this particular case, I don't think the application will start if the vhost is not found. Additionally, if you have configured RMQ to not allow immediate creation of a queue with the provided credentials it may also fail outright as this is a situation where it cannot recover from.

Upvotes: 4

Related Questions