0

如何自定义 aws s3 inbound-channel-adapter 的启动/停止。我想最初设置 auto-startup="false" 并在服务器启动时手动启动。寻找类似于我们有以下文件入站通道适配器解决方案的解决方案。

inboundFileAdapterChannel.send(new GenericMessage("@'s3FilesChannelId.adapter'.start()"));

配置:

如果我对 s3 入站适配器通道尝试相同的方法。我收到以下错误


应用程序无法启动


描述:

一个组件需要一个名为“s3FilesChannelId.adapter”的 bean,但找不到该 bean。

行动:

考虑在您的配置中定义一个名为“s3FilesChannelId.adapter”的 bean。

4

1 回答 1

0

假设我们有一个这样的通道适配器:

<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#控制总线

于 2018-10-09T13:59:39.387 回答