java - org.springframework.integration.dsl.filter(...) 方法发生内部异常
问题描述
当运行时异常源自 org.springframework.integration.dsl.IntegrationFlowDefinition.filter(...) 方法的执行范围时,我们观察到 DLQ 消息在 RabbitMq 中缺少跟踪堆栈。
例如,使用以下代码片段:
@Bean
IntegrationFlow accountingMovementFlow(final Function<AccountingMovement, AccountingMovement> tranMoveMapValEnricher, final MessageChannel auditDiscardChannel, final Clock clock
) {
return from("dltmvChannel")
.transform(Message.class, message -> (Message<?>) MessageBuilder.fromMessage(message)
.setHeader(SINK_STARTED_TIMESTAMP, LocalDateTime.ofInstant(clock.instant(), ZoneId.of("UTC")).toString())
.build())
.transform(new AccountingMovementMapper())
.filter(AccountingMovement::isValidOperationType,
discardFlow -> discardFlow.discardChannel(auditDiscardChannel))
.filter(AccountingMovement.class, accountingMovement -> accountingMovement.getAccountBusinessDate().isBefore(accountingMovement.getMovementEffectiveDate()),
discardFlow -> discardFlow.discardChannel(auditDiscardChannel))
.transform(tranMoveMapValEnricher::apply)
.filter(AccountingMovement.class, accountingMovement -> !accountingMovement.isExistingMovement(),
discardFlow -> discardFlow.discardChannel(auditDiscardChannel))
.channel("accountingMovementEnricherChannel")
.get();
}
假设 AccountBusinessDate 为空。执行accountingMovement.getAccountBusinessDate().isBefore(accountingMovement.getMovementEffectiveDate())会立即触发NullPointerException。在这种情况下,流入“dltmvChannel”的消息将存储在带有跟踪堆栈的 DLQ 中。然而,这并没有发生。
我们跟踪/调试了 .filter(...) 方法,发现内部执行实际上触发了另一个解析异常,因为原始运行时异常正在冒泡。因此,DLQ 的消息缺少跟踪堆栈。
我们在 org.springframework.integration.dsl.IntegrationFlowDefinition 的其他方法中看不到这种行为。例如,如果 tranMoveMapValEnricher::apply 在执行 org.springframework.integration.dsl.IntegrationFlowDefinition.transform(...) 时触发运行时异常,则该消息将使用跟踪堆栈进行 DLQ。
解决方案
推荐阅读
- php - PHP嵌套数组循环未定义级别
- node.js - RabbitMQ 有一个专属的consumer 串行消费消息
- python - 你能直接用 Fortran 代码包装 Python 吗?
- xunit - 如果没有执行断言,如何使 xUnit 失败?
- sql - 在同一个表中嵌套 SELECT 和 CASE 语句
- swift - 以编程方式添加文本字段以滚动视图?
- c# - X509Certificate2 Constructor Throwing 磁盘空间不足
- sql - 为什么多个 EXISTS 会破坏查询
- python - Pygame - 即使我正在更新我的图像,也会出现奇怪的踪迹。这是怎么回事?
- amazon-web-services - 无法在 UserData AWS EC2 cloudformation 中写入文件的内容