【问题标题】:Spring Integration with Azure blob storage using xmlSpring 使用 xml 与 Azure blob 存储集成
【发布时间】:2019-02-11 13:20:29
【问题描述】:

使用文件适配器,我有一个以固定速率轮询的入站通道,从目录读取文件,过滤某些文件,最后对它们进行排序并将它们发送到出站网关,出站网关再次移动文件以供服务 bean 处理。

<bean id="baseDirectory" class="java.lang.String">
    <constructor-arg value="${HOME}/user/files/"/>
</bean>

<file:inbound-channel-adapter id="testFiles" directory="#{baseDirectory}" filename-regex="^(test_filename.*)-(\d+)\.csv" comparator="someFileOrderComparator">
    <int:poller fixed-rate="6000"/>
</file:inbound-channel-adapter>

<file:outbound-gateway request-channel="testFiles" reply-channel="testFile" directory="#{baseDirectory}/processing" delete-source-files="true”/>

<int:service-activator input-channel="testFile" ref="someServiceTask" method="executeTask”/>

这是我们如何从文件系统中读取文件的示例。

假设我想从 Azure blob 存储中读取文件,假设我有一个包含文件夹 A 的容器 X。使用帐户名和帐户访问密钥如何告诉 spring Integration 从容器 X 的文件夹 A 中读取文件.

首选 XML 配置。

【问题讨论】:

    标签: spring azure spring-integration


    【解决方案1】:

    我遇到了与您面临的问题类似的问题。 这是我解决它的方法 -

    1. 创建了一个CloudStorageAccount的bean(你可以很容易地把它转换成xml配置。我不习惯xml配置。) -

      @Bean CloudStorageAccount getAccount(String connString){ return CloudStorageAccount.parse(connString); }

    2. 使用 AzureStorageProtocolResolver -

    AzureStorageProtocolResolver fileResolver = new AzureStorageProtocolResolver(); File resolvedFile = fileResolver.resolve("azure-blob://<containerName>/<Path to File(e.g. "lib/myfile.jar")>").getFile();

    AzureStorageProtocolResolver 是一个 Azure 类,将在内部使用来自 beanfactory 的 StorageAccount bean。 见-https://github.com/Microsoft/spring-cloud-azure/blob/master/spring-cloud-azure-storage/src/main/java/com/microsoft/azure/spring/cloud/storage/AzureStorageProtocolResolver.java

    还有另一种方法可以使用 Azure Spring Boot Starter。 见-https://github.com/Microsoft/azure-spring-boot/tree/master/azure-spring-boot-starters/azure-storage-spring-boot-starter

    【讨论】:

    • 这听起来像是在 spring-cloud-azure 项目中支持用于 Azure Blob 的 Spring Integration Channel Adapters 的好请求!
    猜你喜欢
    • 2021-08-15
    • 2018-09-23
    • 2022-07-11
    • 2018-07-09
    • 1970-01-01
    • 2017-08-12
    • 2014-05-04
    • 1970-01-01
    • 2020-09-19
    相关资源
    最近更新 更多