1

有没有办法告诉 spring bus 重命名它的 rabbitmq 队列?在启动时,它们似乎只是一些随机值,如下所示:

springCloudBus.anonymous.4zzIP0z-TH6oIza5mCun7Q

试图让 spring bus 将其重命名为更易于阅读的可预测队列名称。例如:

testQueue

或者知道它为什么服务保存消息的东西。

我尝试将以下内容添加到 bootRun 上的 application.yml:

spring:
   cloud: 
     stream:
       bindings:
         output:
           destination: testQueue

无济于事。请帮忙!!

4

2 回答 2

3

NOTE: anonymous groups are essential for Spring Cloud Bus to work properly.

using a group makes

a) the subscription durable which means that apps will receive all events (including the ones that have been sent while they were not running)

b) using groups means that apps can become competing consumers which means that the events are not broadcast

c) queues are not deleted automatically anymore

The destination you set in spring-cloud-bus inbound/outbound channels are the rabbitmq exchanges not the queues.

For spring-cloud-bus the outbound channel name is springCloudBusOutput.

Hence, your configuration needs to be: spring: cloud: stream: bindings: springCloudBusOutput: destination: testExchange Here the destination name testExchange is the exchange name not the queue name. To avoid anonymous name in the queue, you can set a group name for inbound channel binding.

spring: cloud: stream: bindings: springCloudBusInput: destination: testExchange group: testQueue

This will make the queue name testExchange.testQueue

于 2016-10-19T05:11:47.687 回答
0

我最近这样做是这样的:

spring:
  cloud:
    stream:
      rabbit:
        default:
          consumer:
            anonymousGroupPrefix: ${spring.application.name}-${server.port}.

它重命名所有匿名队列,这非常有用。

于 2021-09-28T18:43:20.130 回答