第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

列出遠(yuǎn)程服務(wù)器目錄中的文件名

列出遠(yuǎn)程服務(wù)器目錄中的文件名

Smart貓小萌 2022-05-21 14:02:03
我想遞歸地列出遠(yuǎn)程目錄及其子目錄中的文件。我知道可以通過(guò)調(diào)用 ListGateway 的 listFiles 方法來(lái)做到這一點(diǎn):列表列表 = listGateway.listFiles("/ussama/providers")@MessagingGatewaypublic interface ListGateway {    @Gateway(requestChannel = "listSftpChannel")    List<File> listFiles(String dir);}@Bean@ServiceActivator(inputChannel = "listSftpChannel")public MessageHandler handler() {    SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sftpSessionFactory(), "ls", "'/directory'");    return  sftpOutboundGateway;}@Beanpublic IntegrationFlow sftpOutboundListFlow() {    return IntegrationFlows.from("listSftpChannel")            .handle(new SftpOutboundGateway(sftpSessionFactory(), "ls", "payload")            ).get();}但我想每隔 x 分鐘做一次。有沒(méi)有辦法可以輪詢遠(yuǎn)程目錄以在每 x 分鐘后列出文件。請(qǐng)給java配置。
查看完整描述

1 回答

?
紫衣仙女

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊

輪詢目錄的簡(jiǎn)單 POJO 消息源并根據(jù)需要配置輪詢器...


@Bean

public IntegrationFlow pollLs(SessionFactory<LsEntry> sessionFactory) {

    return IntegrationFlows.from(() -> "foo/bar", e -> e

                .poller(Pollers.fixedDelay(5, TimeUnit.SECONDS)))

            .handle(Sftp.outboundGateway(sessionFactory, Command.LS, "payload")

                    .options(Option.RECURSIVE))

            .handle(System.out::println)

            .get();

}

顯然,您將需要一些服務(wù).handle來(lái)接收List<LsEntry>結(jié)果。


順便說(shuō)一句,有一個(gè)工廠類Sftp可以方便地創(chuàng)建端點(diǎn)。


查看完整回答
反對(duì) 回復(fù) 2022-05-21
  • 1 回答
  • 0 關(guān)注
  • 181 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)