java-Spring Integration-应用程序代码中的调用方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-Spring Integration-应用程序代码中的调用方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2544字,纯文字阅读大概需要4分钟。
内容图文
我有一个outbound-channel-adapter,其相关配置如下所示.
<int:outbound-channel-adapter channel="foo-fileChannel" ref="foo-handlerTarget" method="handleFeedFile">
<int:poller fixed-delay="5000" receive-timeout="1000" max-messages-per-poll="10" />
</int:outbound-channel-adapter>
<int:channel id="foo-fileChannel">
<int:queue />
</int:channel>
<bean id="foo-handlerTarget" class="com.abc.FooFeedHandlerImpl">
<property name="fooDescriptorFile" value="${feed.foo.fooDescriptorFile}" />
<property name="fileIdRegex" ref="foo-fileRegex" />
<property name="processId" value="${feed.processId}" />
<property name="workingLocation" value="${feed.foo.workingLocation}" />
<property name="remoteLocation" value="${feed.foo.remoteLocation}" />
<property name="stalenessThreshold" value="${feed.foo.stalenessThreshold}" />
</bean>
在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)方法.
解决方法:
您可能要参考F.6 Message Mapping rules and conventions.
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表达式来调用预期的方法:
3.3.2 Configuring An Outbound Channel Adapter
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.
内容总结
以上是互联网集市为您收集整理的java-Spring Integration-应用程序代码中的调用方法全部内容,希望文章能够帮你解决java-Spring Integration-应用程序代码中的调用方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。