简体   繁体   English

RabbitMQ-未找到停止Spring服务器的队列

[英]RabbitMQ - no queue found stopping Spring server

I have a spring application which is consuming messages from rabbitmq. 我有一个Spring应用程序,它正在使用来自Rabbitmq的消息。 However, the spring server fails to start when the RabbitMQ server is down. 但是,当RabbitMQ服务器关闭时,spring服务器无法启动。

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应用程序启动吗?

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 问候,法罕

The error message states that it is unable to find the vhost named test_queue . 错误消息指出,它找不到名为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. 此外,如果已将RMQ配置为不允许立即使用提供的凭据创建队列,则它也可能会彻底失败,因为这是无法恢复的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM