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

2024-01-10 15:59 更新

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

這是有關如何配置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;
}
以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號