Mikhail Gordienko
Mikhail Gordienko

Reputation: 119

How to properly create Spring Cloud Task with custom parameters?

According to the samples here (actually - timestamp task), I have implemented a small task class:

@SpringBootApplication
@EnableTask
@EnableConfigurationProperties({ RestProcessorTaskProperties.class })
public class RestProcessorTaskApplication {
    public static void main(String[] args) {
        SpringApplication.run(RestProcessorTaskApplication.class, args);
    }

    @Autowired
    private RestProcessorTaskProperties config;

    // some fields and beans

    @Bean
    public CommandLineRunner run(RestTemplate restTemplate) {
        return args -> {
            // doing some stuff
        };
    }
}

and then I've created Properties class (in the same package)

@ConfigurationProperties("RestProcessor")
public class RestProcessorTaskProperties {
    private String host = "http://myhost:port";

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }
}

But after I've registered task on my local Spring Cloud Data Server, I see numerous parameters, that, I suppose, was added automatically. I those mean parameters like:

abandon-when-percentage-full            java.lang.Integer       
abandoned-usage-tracking                java.lang.Boolean       
acceptors                               java.lang.Integer       
access-to-underlying-connection-allowed java.lang.Boolean

and others...

Is it possible somehow to hide (or remove) them, so that when launching task I could configure only those parameters, that was added by me (single host property in my example above)?

Upvotes: 0

Views: 1550

Answers (1)

Glenn Renfro
Glenn Renfro

Reputation: 306

By default Spring Cloud Data Flow will show you all the available properties for a boot application. However, you can create a whitelist of properties that you wish to show.
Here is a link to the Spring Cloud Data Flow reference doc that will discuss how to do this: http://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#spring-cloud-dataflow-stream-app-whitelisting.

And here is link to the timestamp starter app that has an example of this: https://github.com/spring-cloud/spring-cloud-task-app-starters/tree/master/spring-cloud-starter-task-timestamp

Upvotes: 1

Related Questions