在Spring Cloud Stream中为特定供应商配置轮询器
我有一个与多个供应商的申请。因此,我正在尝试为Spring Cloud Stream中的特定供应商配置在Spring Cloud Stream中为特定供应商配置轮询器,spring,spring-cloud-stream,poller,Spring,Spring Cloud Stream,Poller,我有一个与多个供应商的申请。因此,我正在尝试为Spring Cloud Stream中的特定供应商配置固定延迟。例如: 应用程序.yaml spring: cloud: function: definition: produce;produce2 stream: poller: produce: fixedDelay: 10000L
固定延迟。例如:
应用程序.yaml
spring:
cloud:
function:
definition: produce;produce2
stream:
poller:
produce:
fixedDelay: 10000L
produce2:
fixedDelay: 5000L
bindings:
produce-out-0:
destination: string-output
produce2-out-0:
destination: string-output-2
代码片段
@Configuration
public class ProducerConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(ProducerConfiguration.class);
@Bean
public Supplier<Object> produce() {
return () -> {
LOGGER.info("message");
return "message";
};
}
@Bean
public Supplier<Object> produce2() {
return () -> {
LOGGER.info("message-2");
return "message-2";
};
}
}
@配置
公共类生产者配置{
私有静态最终记录器Logger=LoggerFactory.getLogger(ProducerConfiguration.class);
@豆子
公共供应商产品(){
返回()->{
LOGGER.info(“消息”);
返回“消息”;
};
}
@豆子
公共供应商产品2(){
返回()->{
LOGGER.info(“消息-2”);
返回“message-2”;
};
}
}
但根据spring的文档,它似乎只能为应用程序中的整个供应商配置org.springframework.cloud.stream.config.DefaultPollerProperties
bean。这是正确的吗?事实上,函数式编程模型目前不支持这一点,因为它确实违反了spring cloud stream设计的微服务的概念,其中一个主要原则是您做一件事,并且在不影响其他人的情况下把它做好。在您的情况下(尤其是在源代码中),在单个JVM进程中有多个微服务组合在一起,因此一个服务影响另一个服务
这样说,自由地考虑,所以我们可以考虑添加这个特性