【问题标题】:How to start/stop nt-aws:s3-inbound-channel-adapter manually如何手动启动/停止 nt-aws:s3-inbound-channel-adapter
【发布时间】:2018-10-09 11:35:06
【问题描述】:

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

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

配置:

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


应用程序启动失败


说明:

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

行动:

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

【问题讨论】:

  • 你需要展示你的配置。

标签: spring spring-boot spring-integration spring-integration-aws


【解决方案1】:

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

<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#control-bus

【讨论】:

  • 非常感谢Artem。它按预期工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-21
相关资源
最近更新 更多