我正在使用 java dsl 配置 sfp 出站流。
网关:
@MessagingGateway
public interface SftpGateway {
@Gateway(requestChannel = "sftp-channel")
void sendFiles(List<Message> messages);
}
配置:
@Bean
public IntegrationFlow sftpFlow(DefaultSftpSessionFactory sftpSessionFactory) {
return IntegrationFlows
.from("sftp-channel")
.split()
.handle(Sftp.outboundAdapter(sftpSessionFactory, FileExistsMode.REPLACE)
.useTemporaryFileName(false)
.remoteDirectory(REMOTE_DIR_TO_CREATE).autoCreateDirectory(true)).get();
}
@Bean
public DefaultSftpSessionFactory sftpSessionFactory() {
...
}
如何配置流程以使我的网关回复失败的消息?换句话说,我希望我的网关能够返回失败的消息列表,而不是无效的。
我用@MessagingGateway(errorChannel = "errorChannel") 标记了网关
并写了错误通道
@Bean
public IntegrationFlow errorFlow() {
return IntegrationFlows.from("errorChannel").handle(new GenericHandler<MessagingException>() {
public Message handle(MessagingException payload, Map headers) {
System.out.println(payload.getFailedMessage().getHeaders());
return payload.getFailedMessage();
}
})
.get();
}
@Bean
public MessageChannel errorChannel() {
return MessageChannels.direct().get();
}
如果出现一些错误(即没有连接到 SFTP),我只会收到一个错误(列表中第一条消息的有效负载)。我应该把建议放在哪里来汇总所有消息?