如何手动启动/停止 nt-aws:s3-入站通道适配器



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

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

配置:

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


应用程序无法启动


描述:

组件需要一个名为"s3FilesChannelId.adapter"的 Bean,但找不到。

行动:

考虑在配置中定义一个名为"s3FilesChannelId.adapter"的 Bean。

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

<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"

因此,它不会在应用程序上下文初始化后自动启动。 但是,使用该s3Inboundid,我们可以在方便的时候手动执行此操作。

您关于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

最新更新