在spring boot-集成中,有一个过滤器将重命名文件,如果实例仅成功重命名了文件,它将继续执行流程,否则它将被传递到null通道。
想登录空通道以查看未成功重命名的文件名。
尝试以下解决方案。但是在应用程序启动期间发生异常。您能提出解决方案的建议吗?
<integration:filter input-channel="filesInChannel" expression="headers['file_originalFile'].renameTo(new java.io.File(headers['file_originalFile'].absolutePath + '.lock'))"
output-channel="filesHeaderEnricher" discard-channel="nullChannel" throw-exception-on-rejection="false">
</integration:filter>
<integration:channel id="nullChannel">
<integration:interceptors>
<integration:wire-tap channel="logNullChannel"/>
</integration:interceptors>
</integration:channel>
<integration:logging-channel-adapter id="logNullChannel" level="DEBUG"/>
如果为nullchannel添加了logging-channel-adapter,则为异常:
java.lang.IllegalStateException: The bean name 'nullChannel' is reserved.
at org.springframework.integration.config.DefaultConfiguringBeanFactoryPostProcessor.registerNullChannel(DefaultConfiguringBeanFactoryPostProcessor.java:112) ~[spring-integration-core-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at org.springframework.integration.config.DefaultConfiguringBeanFactoryPostProcessor.postProcessBeanFactory(DefaultConfiguringBeanFactoryPostProcessor.java:63) ~[spring-integration-core-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]
at
答案 0 :(得分:1)
nullChannel
根本无法被截获。您需要为用例考虑一些其他渠道,或者为NullChannel
类别打开调试日志记录:
if (this.loggingEnabled && this.logger.isDebugEnabled()) {
this.logger.debug("message sent to null channel: " + message);
}