dashaun/interface-client-config-spring-boot-4-1

Good questions, get good answers. A reference implementation of configuring http interface clients.

★ 0Forks 0JavaGitHub ↗Compare

README

interface-client-config

A minimal Spring Boot 4.1 example that configures the underlying client of a declarative HTTP interface using a group configurer (RestClientHttpServiceGroupConfigurer).

The "echo" group's client uses 100 threads and a 30s connection timeout:

@Bean
RestClientHttpServiceGroupConfigurer echoGroupConfigurer(ExecutorService echoClientExecutor) {
    ClientHttpRequestFactory requestFactory = ClientHttpRequestFactoryBuilder.jdk()
            .withExecutor(echoClientExecutor)                 // 100 threads
            .build(HttpClientSettings.defaults()
                    .withConnectTimeout(Duration.ofSeconds(30))); // 30s connection timeout

    return groups -> groups.filterByName("echo")
            .forEachClient((group, clientBuilder) -> clientBuilder
                    .baseUrl("https://echo.zuplo.io")
                    .requestFactory(requestFactory));
}

Uses the modular spring-boot-starter-restclient — no servlet container (Tomcat).

Run

mvn spring-boot:run

Reference documentation

Contributors

dashaun

Issues