Reputation: 1173
I am using spring integration to download files and to process them.
<int-sftp:inbound-channel-adapter channel="FileDownloadChannel"
session-factory="SftpSessionFactory"
remote-directory="/home/sshaji/from_disney/files"
filter = "modifiedFileListFilter"
local-directory="/home/sshaji/to_disney/downloads"
auto-create-local-directory="true" >
<integration:poller cron="*/10 * * * * *" default="true"/>
</int-sftp:inbound-channel-adapter>
<integration:transformer input-channel="FileDownloadChannel"
ref="ErrorTransformer"
output-channel="EndChannel"/>
The execution is started by the poller. It calls the "FileDownloadChannel" and then tries to download files from the sftp server. I want to specify an output channel for this inbound-channel-adaptor but it doesnot have any output-channel attribute.
So i named the transformer with the same name as that of inbound-channel-adaptor so that it will also be called once poller starts.
My issue is that the transformer gets called before the download happens and hence transformer wont get any inputs to process and causes error.
Is there any way we can specify "order" attribute for this two tasks. or is there any workaround for the output-channel for the inbound-channel adaptor?.
I would really appreciate any help on this.
Upvotes: 1
Views: 1986
Reputation: 4029
A Channel Adapter is a Message Endpoint that enables connecting a single sender or receiver to a Message Channel.
In your case, output channel is 'FileDownloadChannel'
<integration:channel id="FileDownloadChannel"/>
<int-sftp:inbound-channel-adapter channel="FileDownloadChannel" ...>
<integration:poller fixed-rate="10000"/>
</int-sftp:inbound-channel-adapter>
In order to execute your tasks in order, you can use the Message Handler chain as follows:
<integration:channel id="outputChannel"/>
<chain input-channel="FileDownloadChannel" output-channel="outputChannel">
<filter ref="someSelector" throw-exception-on-rejection="true"/>
<transformer ref="ErrorTransformer"/>
<service-activator ref="someService" method="someMethod"/>
</chain>
Upvotes: 0
Reputation: 174534
You need to read the Spring Integration Reference Manual and work through some sample applications.
Channel adapters don't have input and output channels, they have channel
s. Channel adapters either produce or consume a message (inbound Vs outbound) on their channel
. Elements such as transformers, service activators etc, that receive a message and produce a reply, have input and output channels.
"My issue is that the transformer gets called before the download happens and hence transformer wont get any inputs to process and causes error."
This statement makes no sense to me; if there's no file yet, there's nothing to "call" the transformer with.
"attribute for this two tasks."
There are not two "tasks".
The poller thread invokes the inbound adapter; then, when a file arrives, it is sent as a message to the configured channel
which, with your configuration, means the poller thread invokes the transformer with the message.
Upvotes: 0