SpringCloudStream正在消费者服务启动时创建exchange
我有两个微服务SpringCloudStream正在消费者服务启动时创建exchange,spring,microservices,spring-cloud-stream,spring-rabbit,Spring,Microservices,Spring Cloud Stream,Spring Rabbit,我有两个微服务Student和Teacher 在Studentmicroservice中,我正在为exchangeXYZ @Input("XYZ") SubscribableChannel xyz(); 在Teachermicroservice中,我正在将exchangeXYZ配置为fanout 应用程序属性 spring.cloud.stream.rabbit.bindings.XYZ.producer.exchangeType=fanout spring.cloud.stream.bi
Student
和Teacher
在Student
microservice中,我正在为exchangeXYZ
@Input("XYZ")
SubscribableChannel xyz();
在Teacher
microservice中,我正在将exchangeXYZ
配置为fanout
应用程序属性
spring.cloud.stream.rabbit.bindings.XYZ.producer.exchangeType=fanout
spring.cloud.stream.bindings.XYZ.contentType=application/json
但我在这里面临的问题是学生
服务在教师
服务之前启动,它正在创建XYZ交换
,类型为主题
,然后教师
服务启动给我以下错误:
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)
amqp.rabbit.core.RabbitAdmin-未能声明交换:交换[name=XYZ,type=fanout,durable=true,autoDelete=false,internal=false,arguments={}],继续。。。com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:#方法(回复代码=406,回复文本=Premission_失败-vhost'/'中交换'XYZ'的参数'type'不相等:收到'fanout',但当前为'topic',类id=40,方法id=10)
>是否有更改“<代码> Exchange Type <代码> >或删除现有<代码> Exchange < /代码>并创建新<代码> Exchange < /代码>或设置<代码> Exchange Eype PE > <代码> > <输入> <代码>
< p>可考虑通过配置属性禁用Exchange创建:declareExchange
Whether to declare the exchange for the destination.
Default: true.
可以考虑通过配置属性禁用Exchange创建:
declareExchange
Whether to declare the exchange for the destination.
Default: true.
您还可以在使用者端设置
交换类型。如果您使用的是自定义交换类型,则两边的交换类型必须相同。找到exchangeType
,您可以看到它对生产者和消费者都可用。您还可以在消费者端设置exchangeType
。如果您使用的是自定义交换类型,则两边的交换类型必须相同。找到exchangeType
,您可以看到它对生产者和消费者都可用。