Thats a summarize of the code
The spring integration config regarding this case
Code:
[...]
<channel id="channel1">
<queue capacity="1000"/>
</channel>
<publish-subscribe-channel id="channel2" />
<bridge input-channel="channel1"
output-channel="channel2">
<poller max-messages-per-poll="16" fixed-rate="10000"/>
</bridge>
<sftp:outbound-channel-adapter channel="channel2"
session-factory="sftpSessionFactory"
remote-directory="${sftp.dir}"
temporary-file-suffix="uploading"/>
<service-activator input-channel="errorChannel"
output-channel="nullChannel"
ref="myServiceActivator"
method="handleError"/>
[...]
MyService
Code:
public class MyServiceImpl {
@Autowired
@Qualifier("channel1") // or "channel2"
private MessageChannel sftpChannel;
public boolean uploadFile(String filename) {
try {
sftpChannel.send(MessageBuilder.withPayload(filename)).build());
return true;
} catch (Exception e) {
return false;
}
}
}
MyServiceActivator
Code:
public class MyServiceActivator {
public void handleError(MessagingException e) {
// Logging and process
}
}
Thanks