无法声明队列:[jsa.tank]

时间:2019-09-04 13:17:15

标签: spring spring-boot rabbitmq message-queue spring-rabbitmq

我正在做什么,我在春季启动时在application.properties上配置了一些队列,然后尝试与exchanges.bind绑定。在春季启动的配置类中创建bean,但是当我启动应用程序时遇到此问题。 / p>

这是我的文件,请告诉我我在哪里做错了。异常日志如下。

Application.properties文件

#================RabbitMq configuration==================================
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest


#=======================Quese and exchanges====================


jsa.rabbitmq.pdu_queue=jsa.tank
jsa.rabbitmq.pdu_exchange=jsa.pdirect
jsa.rabbitmq.pdu_routingkey=jsa.proutingkey

jsa.rabbitmq.noc_queue=jsa.noc_tank
jsa.rabbitmq.noc_exchange=jsa.noc_direct
jsa.rabbitmq.noc_routingkey=jsa.noc_routingkey

jsa.rabbitmq.qos_queue=jsa.qos_tank
jsa.rabbitmq.qos_exchange=jsa.qos_direct
jsa.rabbitmq.qos_routingkey=jsa.qos_routingkey

jsa.rabbitmq.qos_cellqueue=jsa.qos_celltank
jsa.rabbitmq.qos_cellexchange=jsa.qos_celldirect
jsa.rabbitmq.qos_cellroutingkey=jsa.qos_cellroutingkey

jsa.rabbitmq.cell_queue=jsa.cell_tank
jsa.rabbitmq.cell_exchange=jsa.cell_direct
jsa.rabbitmq.cell_routingkey=jsa.cell_routingkey

#=======================Cuncurrency control====================
debug=false
spring.rabbitmq.listener.simple.concurrency=4
spring.rabbitmq.listener.simple.max-concurrency=8
spring.rabbitmq.listener.simple.retry.initial-interval=5000

还有我的spring配置类

@Configuration
public class RabbitConfig2 {
    final boolean isDurable = true;
    final boolean isExclusive = false;
    final boolean autoDelete = false;

    @Value("${jsa.rabbitmq.pdu_queue}")
    private String pduTank;

    @Value("${jsa.rabbitmq.pdu_exchange}")
    private String pduEexchange;

    @Value("${jsa.rabbitmq.pdu_routingkey}")
    private String pduRoutingKey;

    @Value("${jsa.rabbitmq.noc_queue}")
    private String nocTank;

    @Value("${jsa.rabbitmq.noc_exchange}")
    private String nocExchange;

    @Value("${jsa.rabbitmq.noc_routingkey}")
    private String nocRoutineKey;

    @Value("${jsa.rabbitmq.qos_cellqueue}")
    private String qosCellTank;

    @Value("${jsa.rabbitmq.qos_cellexchange}")
    private String qosCellExchange;

    @Value("${jsa.rabbitmq.qos_cellroutingkey}")
    private String qosCellRoutineKey;

    @Value("${jsa.rabbitmq.qos_queue}")
    private String qosTank;

    @Value("${jsa.rabbitmq.qos_exchange}")
    private String qosExchange;

    @Value("${jsa.rabbitmq.qos_routingkey}")
    private String qosRoutineKey;

    @Value("${jsa.rabbitmq.qos_cellqueue}")
    private String cellTank;
    @Value("${jsa.rabbitmq.qos_cellexchange}")
    private String cellExchange;
    @Value("${jsa.rabbitmq.qos_cellroutingkey}")
    private String cellRoutineKey;

    /********************* Application Queues **********************/
    @Bean
    Queue pduQueue() {
        return QueueBuilder.durable(pduTank).build();
    }

    @Bean
    Queue nocQueue() {
        return new Queue(nocTank, isDurable, isExclusive, autoDelete);
    }

    @Bean
    Queue qosQueue() {
        return new Queue(qosTank, isDurable, isExclusive, autoDelete);
    }

    @Bean
    Queue qosCellQueue() {
        return new Queue(qosCellTank, isDurable, isExclusive, autoDelete);
    }

    @Bean
    Queue cellQueue() {
        return new Queue(cellTank, isDurable, isExclusive, autoDelete);
    }

    /********************* Application Exchanges **********************/

    @Bean
    DirectExchange pduExchange() {
        return new DirectExchange(pduEexchange);
    }

    @Bean
    DirectExchange nocExchange() {
        return new DirectExchange(nocExchange);
    }

    @Bean
    DirectExchange qosExchange() {
        return new DirectExchange(qosExchange);
    }

    @Bean
    DirectExchange qosCellExchange() {
        return new DirectExchange(qosCellExchange);
    }

    @Bean
    DirectExchange cellExchange() {
        return new DirectExchange(cellExchange);
    }

    /********************* Application Binding **********************/

    @Bean
    Binding pduBinding() {
        return BindingBuilder.bind(pduQueue()).to(pduExchange())
                .with(pduRoutingKey);
    }

    @Bean
    Binding nocBinding() {
        return BindingBuilder.bind(nocQueue()).to(nocExchange())
                .with(nocRoutineKey);
    }

    @Bean
    Binding qosBinding() {
        return BindingBuilder.bind(qosQueue()).to(qosExchange())
                .with(qosRoutineKey);
    }

    @Bean
    Binding qosCellBinding() {
        return BindingBuilder.bind(qosCellQueue()).to(qosCellExchange())
                .with(qosCellRoutineKey);
    }

    @Bean
    Binding cellBinding() {
        return BindingBuilder.bind(cellQueue()).to(cellExchange())
                .with(cellRoutineKey);
    }



}

这是错误日志

  

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer $ DeclarationException:无法声明队列:[jsa.tank]           在org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:643)〜[spring-rabbit-1.7.3.RELEASE.jar :?]           在org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:542)[spring-rabbit-1.7.3.RELEASE.jar :?]           在org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer $ AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1389)上[spring-rabbit-1.7.3.RELEASE.jar :?]           在java.lang.Thread.run(Thread.java:745)[?:1.8.0_111]       造成原因:java.io.IOException           在com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:992)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)〜[amqp-client-4.0.2.jar:4.0.2]           在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[?:1.8.0_111]           在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[?:1.8.0_111]           在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[?:1.8.0_111]           在java.lang.reflect.Method.invoke(Method.java:498)〜[?:1.8.0_111]           在org.springframework.amqp.rabbit.connection.CachingConnectionFactory $ CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:955)〜[spring-rabbit-1.7.3.RELEASE.jar :?]           在com.sun.proxy。$ Proxy91.queueDeclarePassive(未知来源)〜[?:?]           在org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:622)〜[spring-rabbit-1.7.3.RELEASE.jar :?]           ...另外3个       引起原因:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:#method(回复代码= 404,回复文本= NOT_FOUND-虚拟主机'/'中没有队列'jsa.tank',类ID = 50,方法ID = 10)           在com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel $ BlockingRpcContinuation.getReply(AMQChannel.java:366)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:992)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)〜[amqp-client-4.0.2.jar:4.0.2]           在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[?:1.8.0_111]           在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[?:1.8.0_111]           在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[?:1.8.0_111]           在java.lang.reflect.Method.invoke(Method.java:498)〜[?:1.8.0_111]           在org.springframework.amqp.rabbit.connection.CachingConnectionFactory $ CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:955)〜[spring-rabbit-1.7.3.RELEASE.jar :?]           在com.sun.proxy。$ Proxy91.queueDeclarePassive(未知来源)〜[?:?]           在org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:622)〜[spring-rabbit-1.7.3.RELEASE.jar :?]           ...另外3个       引起原因:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:#method(回复代码= 404,回复文本= NOT_FOUND-虚拟主机'/'中没有队列'jsa.tank',类ID = 50,方法ID = 10)           在com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:143)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:90)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:634)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQConnection.access $ 300(AMQConnection.java:47)〜[amqp-client-4.0.2.jar:4.0.2]           在com.rabbitmq.client.impl.AMQConnection $ Ma

0 个答案:

没有答案