【问题标题】:Camel Azure credentials as option instead of beanCamel Azure 凭据作为选项而不是 bean
【发布时间】:2018-02-16 00:48:59
【问题描述】:

我想将凭据传递给 Azure blob 组件,而无需创建和注册 bean。

我有一个使用文件并将其路由到 Azure Blob 的路由

我希望这条路线是通用的。

我面临的挑战是。

  1. 我必须支持多个存储帐户
  2. 我们应该从密钥保管库中获取凭据。凭据可以随时更改,我无法控制。 blob 组件需要一个 bean 作为凭证​​。所以我剩下的唯一选择是豆子。因此,虽然我能够做到这一点,但想知道骆驼是否应该能够接收凭据,而不是 object 或 client ,而是帐户名和密钥作为选项。 Camel 不支持密钥保管库,这有点令人失望。我也许可以帮助实施密钥保管库解决方案

【问题讨论】:

    标签: azure apache-camel


    【解决方案1】:

    这是我为实现我想要的而编写的 bean。

    from(file://somedir).to(bean:azureService?sendFiletoAzure(name,key,container);

    AzureService{

        public void sendFileToAzure(String storageAccountName,
                String storageAccountKey, String containerName, Exchange exchange) {
            StorageCredentials credentials = new StorageCredentialsAccountAndKey(
                    storageAccountName, storageAccountKey);
            SimpleRegistry registry = new SimpleRegistry();
            GenericFile<?> file = (GenericFile<?>) exchange.getIn().getBody();
            String blobName = (String) exchange.getIn().getHeader("blobName");
            CamelContext context = new DefaultCamelContext(registry);
            registry.put("blobCredentials", credentials);
            String endpointUri = String.format(azureEndpointUri, storageAccountName,
                    containerName, blobName);
            context.createProducerTemplate().sendBody(endpointUri, file);
        }
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 2017-03-05
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多