简体   繁体   English

Spring Amqp无法重新声明交换(XML配置)

[英]Spring amqp cannot redeclare exchange (xml config)

We have an existing project where Rabbitmq exchanges were previously declared in the Spring xml config file. 我们有一个现有项目,先前在Spring xml配置文件中声明过Rabbitmq交换。 Now the company Rabbitmq setup has changed so that exchanges are declared in another project and our project should just publish to a queue in the already declared exchange. 现在,Rabbitmq公司的设置已更改,以便在另一个项目中声明交换,而我们的项目应仅发布到已经声明的交换中的队列中。 The old configuration causes the following exception: 旧的配置导致以下异常:

2015-02-03 13:10:35,374 ERROR [pool-12-thread-1] [CachingConnectionFactory] [] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - cannot redeclare exchange 'exchange.something' in vhost 'something' with different type, durable, internal or autodelete value, class-id=40, method-id=10)

2015-02-03 13:10:35,383 ERROR [pool-10-thread-1] [MqPublishService] [] - Sending message to MQ failed. 2015-02-03 13:10:3​​5,383错误[pool-10-thread-1] [MqPublishService] []-向MQ发送消息失败。 Retrying in next batch job. 在下一个批处理作业中重试。

Is there any way to avoid declaring the exchange when using the Spring and Amqp xml configuration option? 使用Spring和Amqp xml配置选项时,有什么方法可以避免声明交换?

Actually there is no need to declare them at all. 实际上,根本不需要声明它们。 For client application it's just enough to know exchange and queue names and, of course, routing keys. 对于客户端应用程序,仅知道交换和队列名称,当然还有路由密钥就足够了。

From other side, if your application is based on those beans ( <queue> , <exchange> etc.), you just need to remove <admin> . 另一方面,如果您的应用程序基于这些bean( <queue><exchange>等),则只需删除<admin> Only AmqpAdmin is responsible to declare those entities on the Broker. 只有AmqpAdmin负责在代理上声明这些实体。

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

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