Spring Cloudstream 3 + RabbitMQ 配置到现有队列
Spring Cloudstream 3 + RabbitMQ configuration to existing queue
我正在学习 Cloudstream,无法将 cloudstream Function<String, String>
映射到现有队列中。
我只是根据 spring 云文档创建 hello world 应用程序,但并不真正理解 this part regarding binding names。
我的 rabbitmq 应用程序上有 q.test
(现有),但是当我使用此代码和配置时,我的应用程序总是创建新队列 q.test.anonymous.someRandomString
。
有人有这方面的配置示例吗?
@SpringBootApplication
public class CloudstreamApplication {
public static void main(String[] args) {
SpringApplication.run(CloudstreamApplication.class, args);
}
@Bean
public Function<String, String> uppercase() {
return value -> {
System.out.println("Received: " + value);
return value.toUpperCase();
};
}
}
application.yml
spring.cloud.stream:
function.bindings:
uppercase-in-0: q.test
bindings:
uppercase-in-0.destination: q.test
谢谢
参见 the binder documentation - Using Existing Queues/Exchanges。
If you have an existing exchange/queue that you wish to use, you can completely disable automatic provisioning as follows, assuming the exchange is named myExchange
and the queue is named myQueue
:
spring.cloud.stream.bindings.<binding name>.destination=myExhange
spring.cloud.stream.bindings.<binding name>.group=myQueue
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.queueNameGroupOnly=true
我正在学习 Cloudstream,无法将 cloudstream Function<String, String>
映射到现有队列中。
我只是根据 spring 云文档创建 hello world 应用程序,但并不真正理解 this part regarding binding names。
我的 rabbitmq 应用程序上有 q.test
(现有),但是当我使用此代码和配置时,我的应用程序总是创建新队列 q.test.anonymous.someRandomString
。
有人有这方面的配置示例吗?
@SpringBootApplication
public class CloudstreamApplication {
public static void main(String[] args) {
SpringApplication.run(CloudstreamApplication.class, args);
}
@Bean
public Function<String, String> uppercase() {
return value -> {
System.out.println("Received: " + value);
return value.toUpperCase();
};
}
}
application.yml
spring.cloud.stream:
function.bindings:
uppercase-in-0: q.test
bindings:
uppercase-in-0.destination: q.test
谢谢
参见 the binder documentation - Using Existing Queues/Exchanges。
If you have an existing exchange/queue that you wish to use, you can completely disable automatic provisioning as follows, assuming the exchange is named
myExchange
and the queue is namedmyQueue
:
spring.cloud.stream.bindings.<binding name>.destination=myExhange
spring.cloud.stream.bindings.<binding name>.group=myQueue
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.queueNameGroupOnly=true