Class CommonInternalServiceClientConnectorFactory
Builds ClientHttpConnectors for internal service-to-service communication on top of the
shared, observable connection pool (commonIntlSvcConnectionProvider) and the common
broadleaf.common.ssl-verification.disabled policy.
Most Broadleaf services intentionally declare their own connector bean (ex:
pricingClientHttpConnector, interlinkClientHttpConnector) rather than consuming
the central commonIntlSvcClientConnector, so that each service remains individually
overridable. That is a deliberate design decision, but it previously meant every one of those
connectors ended up on Reactor Netty's anonymous global HttpResources pool, where
connection saturation cannot be measured. This factory closes that gap without taking the
per-service beans away: a service keeps its own bean and simply builds it from here.
@Bean
@ConditionalOnMissingBean(name = "pricingClientHttpConnector")
public ClientHttpConnector pricingClientHttpConnector(
CommonInternalServiceClientConnectorFactory connectorFactory) {
return connectorFactory.createConnector();
}
Services that need to customize the underlying client first (wiretap logging, response timeouts,
proxy settings, and so on) can start from createHttpClient() and hand the result back to
createConnector(HttpClient), which keeps them on the shared pool while still applying
the common SSL policy.
- Since:
- MicroExtensionCommon 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCommonInternalServiceClientConnectorFactory(CommonInternalServiceSSLVerificationProperties sslVerificationProperties, reactor.netty.resources.ConnectionProvider connectionProvider) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.client.reactive.ClientHttpConnectorCreates the connector for internal service-to-service communication: the shared connection pool plus the common SSL verification policy.org.springframework.http.client.reactive.ClientHttpConnectorcreateConnector(reactor.netty.http.client.HttpClient httpClient) Applies the common SSL verification policy to an already-customizedHttpClient.reactor.netty.http.client.HttpClientCreates anHttpClientbound to the shared internal connection pool, with no SSL policy applied yet.unpooled(CommonInternalServiceSSLVerificationProperties sslVerificationProperties) Creates a factory with no shared connection pool, applying only the common SSL policy.
-
Constructor Details
-
CommonInternalServiceClientConnectorFactory
public CommonInternalServiceClientConnectorFactory(CommonInternalServiceSSLVerificationProperties sslVerificationProperties, @Nullable reactor.netty.resources.ConnectionProvider connectionProvider)
-
-
Method Details
-
unpooled
public static CommonInternalServiceClientConnectorFactory unpooled(CommonInternalServiceSSLVerificationProperties sslVerificationProperties) Creates a factory with no shared connection pool, applying only the common SSL policy.
This exists so that a service's connector bean can depend on the
commonIntlSvcClientConnectorFactorybean optionally. Sliced test contexts (@DataJpaTestand friends) import a service's configuration directly without MicroExtensionCommon's auto-configuration - and are usually not servlet web applications, which that auto-configuration requires - so the factory bean is simply absent there. Falling back to this keeps such contexts starting with exactly the pre-pool behavior instead of failing on an unsatisfied dependency:return connectorFactoryProvider .getIfAvailable(() -> CommonInternalServiceClientConnectorFactory .unpooled(sslVerificationProperties)) .createConnector();- Parameters:
sslVerificationProperties- the internal SSL verification configuration- Returns:
- a factory that builds connectors on Reactor Netty's global pool
-
createHttpClient
public reactor.netty.http.client.HttpClient createHttpClient()Creates anHttpClientbound to the shared internal connection pool, with no SSL policy applied yet. Use this when the client needs further customization before being turned into a connector viacreateConnector(HttpClient).- Returns:
- an unconfigured client on the shared internal connection pool
-
createConnector
@Nullable public org.springframework.http.client.reactive.ClientHttpConnector createConnector()Creates the connector for internal service-to-service communication: the shared connection pool plus the common SSL verification policy.- Returns:
- the connector, or
nullwhen there is nothing to contribute over theWebClientbuilder's own default connector - that is, when the shared pool is disabled and SSL verification is left enabled. Callers should treatnullas "let theWebClientbuilder initialize its default connector". Note thatnullmeans "no opinion", never "something failed"; a broken SSL configuration throws. - Throws:
IllegalStateException- if the insecureSslContextcould not be built
-
createConnector
public org.springframework.http.client.reactive.ClientHttpConnector createConnector(reactor.netty.http.client.HttpClient httpClient) Applies the common SSL verification policy to an already-customized
HttpClient. The caller is responsible for having sourced that client fromcreateHttpClient()if it should participate in the shared connection pool.Unlike
createConnector(), this never returnsnull: the caller has handed over a configured client, and quietly discarding it (timeouts, wiretap, proxy settings and all) in favor of theWebClientbuilder's default connector would be worse than failing. AnSslContextthat cannot be built is a misconfiguration, not a degraded mode.- Parameters:
httpClient- the client to wrap- Returns:
- the connector for the given client, never
null - Throws:
IllegalStateException- if the insecureSslContextcould not be built
-