spring - Spring集成默认输出通道不起作用
问题描述
在我的应用程序中,我试图根据从服务方法返回的 http 状态值进行路由,其余的 http 状态将被路由到默认错误通道。但是这个默认映射不起作用,
@Bean
public IntegrationFlow bridgeFlow() {
return IntegrationFlows.from(ApplicationConfiguration.QUEUE_CHANNEL)
.bridge(e -> e.poller(Pollers.fixedDelay(2500).maxMessagesPerPoll(MAX_MSG_PER_POLL)))
.handle(someService, "someMethod")
.route(router())
.get();
}
public ExpressionEvaluatingRouter router() {
ExpressionEvaluatingRouter router = new ExpressionEvaluatingRouter("headers['httpStatus']");
router.setChannelMapping("422", REJECTED_QUEUE_CHANNEL);
router.setChannelMapping("202", "nullChannel");
router.setChannelMapping("201", "nullChannel");
router.setDefaultOutputChannelName(ORR_FAILED_QUEUE_CHANNEL);// When I receive other status codes it should go into this channel. But it's not going and throwing a runtime exception when a status code other than these is received.
return router;
}
我尝试将默认频道放在 .route(router()).channel(ORR_FAILED_QUEUE_CHANNEL) 和 .route(router()).handle(ORR_FAILED_QUEUE_CHANNEL) 之后。但它在 bean 初始化期间失败,说“currentComponent”(org.springframework.integration.router.ExpressionEvaluatingRouter@1ca574db)是单向“MessageHandler”,不适合配置“outputChannel”。这是集成流程的结束。
解决方案
您缺少false
在路由器上将此选项设置为:
/**
* Specify whether this router should ignore any failure to resolve a channel name to
* an actual MessageChannel instance when delegating to the ChannelResolver strategy.
* @param resolutionRequired true if resolution is required.
*/
public void setResolutionRequired(boolean resolutionRequired) {
推荐阅读
- r - rmpf包错误
- php - 使用 PHP 从字符串计算数学表达式
- html - Flex 孩子没有溢出(它正在崩溃)
- python - dynamodb/python updateitem 在嵌套地图中追加项目
- mysql - 如何从codeigniter中的db获取字段
- sql - 错误:ORA-1033:ORACLE 初始化或关机正在进行中
- java - 在 Spring Boot Junit 中模拟 Resttemplate 失败
- ios - iOS 如何按天、周和每小时 Swift 创建计划本地通知
- android - 我不能在我的 Room 数据库中执行超过一两个插入操作,因为在这些插入操作之后它根本不会保留数据
- android - CardView 不屏蔽父级内部