|
51 | 51 | import com.mongodb.connection.ClusterConnectionMode;
|
52 | 52 | import com.mongodb.connection.ClusterSettings;
|
53 | 53 | import com.mongodb.connection.ConnectionPoolSettings;
|
54 |
| -import com.mongodb.connection.NettyTransportSettings; |
55 | 54 | import com.mongodb.connection.ServerSettings;
|
56 | 55 | import com.mongodb.connection.SocketSettings;
|
57 | 56 | import com.mongodb.connection.SslSettings;
|
| 57 | +import com.mongodb.connection.TransportSettings; |
58 | 58 | import com.mongodb.event.CommandListener;
|
59 | 59 | import com.mongodb.event.ConnectionPoolListener;
|
60 | 60 | import com.mongodb.reactivestreams.client.ReactiveContextProvider;
|
@@ -261,15 +261,19 @@ private MongoClientSettings createMongoConfiguration(String name, MongoClientCon
|
261 | 261 |
|
262 | 262 | MongoClientSettings.Builder settings = MongoClientSettings.builder();
|
263 | 263 |
|
| 264 | + switch (config.transport()) { |
| 265 | + case NETTY: |
| 266 | + // we supports just NIO for now |
| 267 | + if (!vertx.isNativeTransportEnabled()) { |
| 268 | + configureNettyTransport(settings); |
| 269 | + } |
| 270 | + break; |
| 271 | + case ASYNC: |
| 272 | + // no-op since this is the default behaviour |
| 273 | + break; |
| 274 | + } |
| 275 | + |
264 | 276 | if (isReactive) {
|
265 |
| - // we supports just NIO for now |
266 |
| - if (!vertx.isNativeTransportEnabled()) { |
267 |
| - var nettyStreaming = NettyTransportSettings.nettyBuilder() |
268 |
| - .allocator(VertxByteBufAllocator.POOLED_ALLOCATOR) |
269 |
| - .eventLoopGroup(vertx.nettyEventLoopGroup()) |
270 |
| - .socketChannelClass(NioSocketChannel.class).build(); |
271 |
| - settings.transportSettings(nettyStreaming); |
272 |
| - } |
273 | 277 | reactiveContextProviders.stream().findAny().ifPresent(settings::contextProvider);
|
274 | 278 | }
|
275 | 279 |
|
@@ -344,6 +348,14 @@ private MongoClientSettings createMongoConfiguration(String name, MongoClientCon
|
344 | 348 | return settings.build();
|
345 | 349 | }
|
346 | 350 |
|
| 351 | + private void configureNettyTransport(MongoClientSettings.Builder settings) { |
| 352 | + var nettyStreaming = TransportSettings.nettyBuilder() |
| 353 | + .allocator(VertxByteBufAllocator.POOLED_ALLOCATOR) |
| 354 | + .eventLoopGroup(vertx.nettyEventLoopGroup()) |
| 355 | + .socketChannelClass(NioSocketChannel.class).build(); |
| 356 | + settings.transportSettings(nettyStreaming); |
| 357 | + } |
| 358 | + |
347 | 359 | private boolean doesNotHaveClientNameQualifier(Bean<?> bean) {
|
348 | 360 | for (Annotation qualifier : bean.getQualifiers()) {
|
349 | 361 | if (qualifier.annotationType().equals(MongoClientName.class)) {
|
|
0 commit comments