0
votes

How to customize start/stop of aws s3 inbound-channel-adapter . I want to set auto-startup="false" initially and start manually when server starts.Looking for a solution which is similar like we have the below solution for file inbound channel adaptor.

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

Config:

If i try the same approach for s3 inbound adapter channel . I am getting the below error


APPLICATION FAILED TO START


Description:

A component required a bean named 's3FilesChannelId.adapter' that could not be found.

Action:

Consider defining a bean named 's3FilesChannelId.adapter' in your configuration.

1
You need to show your configuration.Gary Russell

1 Answers

0
votes

Let's assume we have a channel adapter like this:

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

Pay attention to the auto-startup="false" and to the id="s3Inbound".

So, it isn't going to be started automatically after application context initialization. However using that s3Inbound id we can do that manually whenever it is convenient for us.

Your story about inboundFileAdapterChannel is not clear though, but you still can inject a Lifecycle for the mentioned channel adapter and perform its start():

@Autowired
@Qualifier("s3Inbound")
private Lifecycle s3Inbound;

...

this.s3Inbound.start();

The piece of code about inboundFileAdapterChannel seems like a reference to the Control Bus approach, but that's already slightly different story: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management-chapter.html#control-bus