Search code examples
spring-cloud-dataflowspring-cloud-dataflow-ui

Why Spring Cloud Dataflow Supplier properties does not appear?


I have configuration properties for de Supplier:

@Data
@NoArgsConstructor
@ConfigurationProperties("sybase.supplier")
public class SybaseSupplierProperties {
    private short canal = 0;
    private int pollSize = 10;
}

I am injecting it on the application:

@SpringBootApplication
@EnableConfigurationProperties(SybaseSupplierProperties.class)
public class SybaseSupplier {

    private final DataSource dataSource;
    private final SybaseSupplierProperties properties;

    @Autowired
    public SybaseSupplier(DataSource dataSource,
                          SybaseSupplierProperties properties) {
        this.dataSource = dataSource;
        this.properties = properties;
    }
}

I have the maven dependency to generate it:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>

It is generated as spring-configuration-metadata.json

{
  "groups": [
    {
      "name": "sybase.supplier",
      "type": "br.com.clamed.daflow.apps.sybasesupplier.SybaseSupplierProperties",
      "sourceType": "br.com.clamed.daflow.apps.sybasesupplier.SybaseSupplierProperties"
    }
  ],
  "properties": [
    {
      "name": "sybase.supplier.canal",
      "type": "java.lang.Short",
      "sourceType": "br.com.clamed.daflow.apps.sybasesupplier.SybaseSupplierProperties",
      "defaultValue": 0
    },
    {
      "name": "sybase.supplier.poll-size",
      "type": "java.lang.Integer",
      "sourceType": "br.com.clamed.daflow.apps.sybasesupplier.SybaseSupplierProperties",
      "defaultValue": 10
    }
  ],
  "hints": []
}

application.properties

spring.cloud.stream.function.bindings.intControleSupplier-out-0=output
spring.cloud.function.definition=intControleSupplier

Internal maven repo is registed.

The app is imported:

app register --name jdbc-sybase-supplier --type source --uri maven://br.com.clamed.cloud.dataflow.apps:jdbc-sybase-supplier:1.0.0-SNAPSHOT

When I use it, properties do not show:

enter image description here

Why?


Solution

  • Not all the properties from spring-configuration-metadata.json would be available when the SCDF server retrieves the application properties. This is to limit the number of properties get loaded at the UI. But this doesn't mean you can't set those properties as application properties. It is just that those properties would be available in the SCDF web UI as well as shell completion as the application properties for you to choose.

    In your case, to make your SybaseSupplierProperties available, you need to add a dataflow configuration file that specifies what properties should be available for SCDF to retrieve when loading the app.

    You either need to specify spring-configuration-metadata-whitelist.properties (deprecated in the recent releases) or dataflow-configuration-metadata-whitelist.properties inside classpath*:/META-INF/ with the properties classes name you want to include as application configuration properties.

    For instance, in your case you would need to the following content in /META-INF/dataflow-configuration-metadata-whitelist.properties :

    configuration-properties.classes=br.com.clamed.daflow.apps.sybasesupplier.SybaseSupplierProperties
    
    

    You can also checkout the documentation on this here