Flowable HTTP Client
Flowable uses an instance of FlowableHttpClient
in the platform to perform HTTP requests.
This Flowable HTTP Client is used in the HTTP Task and the Service Registry REST models.
Flowable has 3 types of implementations:
- Based on Spring
WebClient
- Based on Apache HTTP 5
- Based on Apache HTTP 4
Based on what is available on the classpath that would take precedence. e.g. Spring WebClient
has precedence over Apache HTTP 5, which has a precedence over Apache HTTP 4.
The http client can be configured using the properties with prefix flowable.http
.
The properties are defined here.
Depending on which client is being used there are other customizations options.
Customizing Spring WebClient
v3.14.0+A bean of type FlowableHttpClientWebClientCustomizer
can be used to provide more complex customization of the WebClient.Builder
e.g.
@Configuration(proxyBeanMethods = false)
public class CustomConfiguration {
@Bean
public FlowableHttpClientWebClientCustomizer httpClientCustomizer() {
return webClientBuilder -> {
// Customization
};
}
}
Customizing Apache HTTP Client 5
v3.14.0+A bean of type FlowableHttpClientApacheHttpClient5Customizer
can be used to provide more complex customization of the HttpAsyncClientBuilder
e.g.
@Configuration(proxyBeanMethods = false)
public class CustomConfiguration {
@Bean
public FlowableHttpClientApacheHttpClient5Customizer httpClientCustomizer() {
return clientBuilder -> {
// Customization
};
}
}
If you want to customize the HTTP proxy you can set flowable.http.use-system-properties
to true and then configure the default Java HTTP proxy properties
Customizing Apache HTTP Client 4
v3.14.5+A bean of type FlowableHttpClientApacheHttpClient4Customizer
can be used to provide more complex customization of the HttpClientBuilder
e.g.
@Configuration(proxyBeanMethods = false)
public class CustomConfiguration {
@Bean
public FlowableHttpClientApacheHttpClient4Customizer httpClientCustomizer() {
return clientBuilder -> {
// Customization
};
}
}
If you want to customize the HTTP proxy you can set flowable.http.use-system-properties
to true and then configure the default Java HTTP proxy properties
Multiple FlowableHttpClient(s)
In case multiple FlowableHttpClient
(s) are needed, e.g. a custom one for a specific Service Registry Service Definition Model, then the FlowableHttpClientBuilder
can be used to provide an instance of the default implementation (see here for an example).
e.g.
@Configuration(proxyBeanMethods = false)
public class CustomConfiguration {
@Bean
public FlowableHttpClient customFlowableHttpClient(FlowableHttpClientBuilder<HttpAsyncClientBuilder> flowableHttpBuilder) {
// Replace HttpAsyncClientBuilder with the appropriate builder
return flowableHttpBuilder
.addCustomizer(builder -> {
// Provide customizations
})
.build();
}
@Bean
@Primary
public FlowableHttpClient defaultFlowableHttpClient(FlowableHttpClientBuilder<?> builder) {
return builder.build();
}
}
The use of the HttpAsyncClientBuilder
is an example.
Depending on which client type is the generic should be the appropriate type.
e.g. WebClient.Builder
when using the Spring WebClient, HttpAsyncClientBuilder
when using the Apache HTTP Client 5 and HttpClientBuilder
when using the Apache HTTP Client 4.