我有两个微服务Student
和Teacher
在Student
微服务中我正在创建MessageSink
以进行交换XYZ
@Input("XYZ")
SubscribableChannel xyz();
在Teacher
微服务中,我将交换XYZ
配置为fanout
application.properties
spring.cloud.stream.rabbit.bindings.XYZ.producer.exchangeType=fanout
spring.cloud.stream.bindings.XYZ.contentType=application/json
但我面临的问题是Student
服务是在Teacher
服务之前启动的,它正在创建XYZ exchange
类型Topic
,然后Teacher
服务启动给我以下错误:
amqp.rabbit.core.RabbitAdmin - Failed to declare exchange: Exchange [name=XYZ, type=fanout, durable=true, autoDelete=false, internal=false, arguments={}], continuing... com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'XYZ' in vhost '/': received 'fanout' but current is 'topic', class-id=40, method-id=10)
是否有任何配置可以更改exchangeType
或删除现有exchange
并在exchange
中创建新exchangeType
或设置@Input
?
答案 0 :(得分:2)
您可以考虑通过配置属性禁用交换创建:
declareExchange
Whether to declare the exchange for the destination.
Default: true.