我正在学习Cloudstream,无法将Cloudstream Function<String, String>
映射到现有队列中。我只是从Spring Cloud文档中创建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。
如果您要使用现有的交换/队列,则可以完全禁用自动配置,如下所示,假定交换名为
myExchange
,队列名为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