简体   繁体   中英

Spring amqp cannot redeclare exchange (xml config)

We have an existing project where Rabbitmq exchanges were previously declared in the Spring xml config file. 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. 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. Retrying in next batch job.

Is there any way to avoid declaring the exchange when using the Spring and Amqp xml configuration option?

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> . Only AmqpAdmin is responsible to declare those entities on the Broker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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