假设我们有一个这样的通道适配器:
<int-aws:s3-inbound-channel-adapter id="s3Inbound"
channel="s3Channel"
session-factory="s3SessionFactory"
auto-create-local-directory="true"
auto-startup="false"
delete-remote-files="true"
preserve-timestamp="true"
filename-pattern="*.txt"
local-directory="."
remote-file-separator="\"
local-filename-generator-expression="#this.toUpperCase() + '.a' + @fooString"
comparator="comparator"
temporary-file-suffix=".foo"
local-filter="acceptAllFilter"
remote-directory-expression="'foo/bar'">
<int:poller fixed-rate="1000"/>
</int-aws:s3-inbound-channel-adapter>
注意auto-startup="false"
和id="s3Inbound"
。
因此,它不会在应用程序上下文初始化后自动启动。但是,s3Inbound
只要我们方便,我们就可以使用该 ID 手动执行此操作。
你的故事inboundFileAdapterChannel
虽然不清楚,但你仍然可以Lifecycle
为提到的通道适配器注入一个并执行它start()
:
@Autowired
@Qualifier("s3Inbound")
private Lifecycle s3Inbound;
...
this.s3Inbound.start();
这段代码inboundFileAdapterChannel
似乎是对该Control Bus
方法的引用,但这已经是一个稍微不同的故事:https ://docs.spring.io/spring-integration/docs/current/reference/html/system-management-chapter.html#控制总线