spring - Spring Cloud Stream 配置问题
问题描述
我正在尝试升级旧版应用程序的版本。我正在尝试使用 spring-cloud-stream 开发 amqp 的一部分。我不能在rabbitMQ队列中收听,没有交换(我不能这样改变)我怎样才能为一个队列实现一个监听器?
这是我的 app-properties.yml
cloud:
function:
definition: inputCollector
stream:
default:
contentType: application/json
declareExchange: false
binders:
rabbitmq:
type: rabbit
bindings:
inputCollector-in-0:
queueNameGroupOnly : true
group : collector_result.Collections
binder: rabbitmq
和我的代码
@Configuration
@AllArgsConstructor
public class AnyHandler {
private static final Logger LOG = LoggerFactory.getLogger(InputCollectorHandler.class);
private final CollectorService collectorService;
@Bean
public Consumer<Event> inputCollector() {
return user -> {
LOG.info("event received", user);
try {
anyService.handleCollectorResponse(user);
} catch (Exception e) {
LOG.error("Error processing message: " + user);
}
};
}
}
解决方案
declareExchange: false
必须低于...rabbit.defaults...
或...rabbit.bindings.....consumer.
推荐阅读
- reactjs - 将 React useMemo() 与 TypeScript 一起使用时,不能分配给类型 '() => void' 错误?
- django - DJANGO + JWT 令牌认证
- c# - 如何在 Windows 窗体中用 C# 中的公共 Id 加入不同数据库的两个 MS 访问表
- java - 是否允许在 Xtext 验证器中访问另一个资源?
- mongodb - MongoDB $push 聚合不会保持正确的顺序
- python - 结合来自两个数据帧的热编码
- windows - 如何使用“nsis-web”包创建科尔多瓦电子构建?
- c# - .NET core Semaphore 和 SemaphoreSlim 在 linux 服务器上工作
- ansible - 从每个库存主机的多个项目中循环注册变量
- c# - .Net Core 中的异步委托