我有一个outbound-channel-adapter,其相关配置如下所示.
在FooFeedHandlerImpl中…
public void handleFeedFile(File retrievedFile) {
handleFeedFile(retrievedFile, null);
}
public void handleFeedFile(File retrievedFile, String processKey) {
if (isHandlerForFileName(retrievedFile.getName())) {
processFeed(retrievedFile, processKey);
}
}
问题:
通道适配器调用哪个handleFeedFile方法?
当我使用Spring集成在应用程序代码中调用方法时,如何确定方法参数?
谢谢你的帮助!
编辑:
我在本地运行我的进程(下载了本地SFTP服务器-http://www.coreftp.com/server/index.html),并确定已调用handleFeedFile(File file)方法.
解决方法:
Multiple parameters could create a lot of ambiguity with regards to determining the appropriate mappings. The general advice is to annotate your method parameters with @Payload and/or @Header/@Headers Below are some of the examples of ambiguous conditions which result in an Exception being raised.
和:
Multiple methods:
Message Handlers with multiple methods are mapped based on the same rules that are described above, however some scenarios might still look confusing.
如果您无法注释目标方法,则可以使用SpEL表达式来调用预期的方法:
Like many other Spring Integration components, the and also provide support for SpEL expression evaluation. To use SpEL, provide the expression string via the ‘expression’ attribute instead of providing the ‘ref’ and ‘method’ attributes that are used for method-invocation on a bean. When an Expression is evaluated, it follows the same contract as method-invocation where: the expression for an will generate a message anytime the evaluation result is a non-null value, while the expression for an must be the equivalent of a void returning method invocation.
标签:enterprise-integration,spring,java,spring-integration
来源: https://codeday.me/bug/20191028/1952048.html