Spring Cloud Google Cloud Storage 入站通道適配器

2024-01-10 15:59 更新

Google云端存儲(chǔ)入站通道適配器會(huì)輪詢Google云端存儲(chǔ)桶中的新文件,并將每個(gè)文件以Message負(fù)載的形式發(fā)送到@InboundChannelAdapter批注中指定的MessageChannel。這些文件臨時(shí)存儲(chǔ)在本地文件系統(tǒng)的文件夾中。

這是有關(guān)如何配置Google Cloud Storage入站通道適配器的示例。

@Bean
@InboundChannelAdapter(channel = "new-file-channel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> synchronizerAdapter(Storage gcs) {
  GcsInboundFileSynchronizer synchronizer = new GcsInboundFileSynchronizer(gcs);
  synchronizer.setRemoteDirectory("your-gcs-bucket");

  GcsInboundFileSynchronizingMessageSource synchAdapter =
          new GcsInboundFileSynchronizingMessageSource(synchronizer);
  synchAdapter.setLocalDirectory(new File("local-directory"));

  return synchAdapter;
}
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號