App properties in Spring Cloud Data Flow application

与世无争的帅哥 提交于 2019-12-23 04:24:06

问题


Based on the documentation for Spring Cloud Data Flow (SCDF) only properties that are prefixed by either "deployed." or "app." are considered when deploying an application (be it a source, processor or sink) as part of a stream.

However, I've noticed that besides the prefix, all the properties must be provided as "strings", no matter what their original type is; otherwise, they are simply discarded by SCDF as per this line of code:

    propertiesToUse = DeploymentPropertiesUtils.convert(props);

which does this:

public static Map<String, String> convert(Properties properties) {
    Map<String, String> result = new HashMap<>(properties.size());
    for (String key : properties.stringPropertyNames()) {
        result.put(key, properties.getProperty(key));
    }
    return result;
}

As you can see from the snippet above, it only considers "stringPropertyNames" which filters out anything that is not provided as a "String".

I presume this behaviour is intentional, but why? Why not just pick up all the properties defined by the user with the proper prefix?

Thanks for your support.


回答1:


All the deployment properties are expected to be of Map<String, String> based on the contract set by the deployer SPI.

I believe one of the reasons is to have String key, values being passed to target deployment platform without serialization/de-serialization hurdle. and, using String values is similar to how one could set those key, value properties as environment variables (for example) in the target deployment platform.



来源:https://stackoverflow.com/questions/44267286/app-properties-in-spring-cloud-data-flow-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!