use of reactor.ipc.netty.resources.PoolResources in project reactor-netty by reactor.
the class WebsocketTest method closePool.
@Test
public void closePool() {
PoolResources pr = PoolResources.fixed("wstest", 1);
NettyContext httpServer = HttpServer.create(0).newHandler((in, out) -> out.sendWebsocket((i, o) -> o.options(opt -> opt.flushOnEach()).sendString(Mono.just("test").delayElement(Duration.ofMillis(100)).repeat()))).block(Duration.ofSeconds(30));
Flux<String> ws = HttpClient.create(opts -> opts.port(httpServer.address().getPort()).poolResources(pr)).ws("/").flatMapMany(in -> in.receiveWebsocket().aggregateFrames().receive().asString());
StepVerifier.create(Flux.range(1, 10).concatMap(i -> ws.take(2).log())).expectNextSequence(Flux.range(1, 20).map(v -> "test").toIterable()).expectComplete().verify();
httpServer.dispose();
pr.dispose();
}
use of reactor.ipc.netty.resources.PoolResources in project cf-java-client by cloudfoundry.
the class _DefaultConnectionContext method dispose.
/**
* Disposes resources created to service this connection context
*/
@PreDestroy
public final void dispose() {
getConnectionPool().ifPresent(PoolResources::dispose);
getThreadPool().dispose();
try {
ObjectName name = getByteBufAllocatorObjectName();
if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
}
} catch (JMException e) {
this.logger.error("Unable to register ByteBufAllocator MBean", e);
}
}
use of reactor.ipc.netty.resources.PoolResources in project spring-cloud-gateway by spring-cloud.
the class GatewayAutoConfigurationTests method nettyHttpClientDefaults.
@Test
public void nettyHttpClientDefaults() {
new ReactiveWebApplicationContextRunner().withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, GatewayAutoConfiguration.class)).withPropertyValues("debug=true").run(context -> {
assertThat(context).hasSingleBean(HttpClient.class);
HttpClient httpClient = context.getBean(HttpClient.class);
HttpClientOptions options = httpClient.options();
PoolResources poolResources = options.getPoolResources();
assertThat(poolResources).isNotNull();
// TODO: howto test PoolResources
ClientProxyOptions proxyOptions = options.getProxyOptions();
assertThat(proxyOptions).isNull();
SslContext sslContext = options.sslContext();
assertThat(sslContext).isNull();
});
}
use of reactor.ipc.netty.resources.PoolResources in project spring-cloud-gateway by spring-cloud.
the class GatewayAutoConfigurationTests method nettyHttpClientConfigured.
@Test
public void nettyHttpClientConfigured() {
new ReactiveWebApplicationContextRunner().withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, GatewayAutoConfiguration.class)).withPropertyValues("spring.cloud.gateway.httpclient.ssl.use-insecure-trust-manager=true", "spring.cloud.gateway.httpclient.pool.type=fixed", "spring.cloud.gateway.httpclient.proxy.host=myhost").run(context -> {
assertThat(context).hasSingleBean(HttpClient.class);
HttpClient httpClient = context.getBean(HttpClient.class);
HttpClientOptions options = httpClient.options();
PoolResources poolResources = options.getPoolResources();
assertThat(poolResources).isNotNull();
// TODO: howto test PoolResources
ClientProxyOptions proxyOptions = options.getProxyOptions();
assertThat(proxyOptions).isNotNull();
assertThat(proxyOptions.getAddress().get().getHostName()).isEqualTo("myhost");
SslContext sslContext = options.sslContext();
assertThat(sslContext).isNotNull();
// TODO: howto test SslContext
});
}
use of reactor.ipc.netty.resources.PoolResources in project reactor-netty by reactor.
the class HttpServerTests method testIssue186.
@Test
public void testIssue186() {
NettyContext server = HttpServer.create(0).newHandler((req, res) -> res.status(200).send()).block(Duration.ofSeconds(300));
HttpClient client = HttpClient.create(ops -> ops.connectAddress(() -> server.address()).poolResources(PoolResources.fixed("test", 1)));
try {
doTestIssue186(client);
doTestIssue186(client);
} finally {
server.dispose();
}
}
Aggregations