Skip to content

Commit 3eeab50

Browse files
authored
Merge pull request #1672 from rabbitmq/remove-java-nio-connector
Remove Java NIO frame handler
2 parents cfc64f1 + b1e47bb commit 3eeab50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+42
-3699
lines changed

src/main/java/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import static java.util.concurrent.TimeUnit.MINUTES;
1919

2020
import com.rabbitmq.client.impl.*;
21-
import com.rabbitmq.client.impl.nio.NioParams;
22-
import com.rabbitmq.client.impl.nio.SocketChannelFrameHandlerFactory;
2321
import com.rabbitmq.client.impl.recovery.AutorecoveringConnection;
2422
import com.rabbitmq.client.impl.recovery.RecoveredQueueNameSupplier;
2523
import com.rabbitmq.client.impl.recovery.RetryHandler;
@@ -154,11 +152,9 @@ public class ConnectionFactory implements Cloneable {
154152
private MetricsCollector metricsCollector;
155153
private ObservationCollector observationCollector = ObservationCollector.NO_OP;
156154

157-
private boolean nio = false;
158155
private boolean netty = false;
159156
private FrameHandlerFactory frameHandlerFactory;
160157
private final NettyConfiguration nettyConf = new NettyConfiguration(this);
161-
private NioParams nioParams = new NioParams();
162158

163159
private SslContextFactory sslContextFactory;
164160

@@ -917,9 +913,6 @@ public ConnectionFactory useSslProtocol(SSLContext context) {
917913
* com.rabbitmq.client.ConnectionFactory.NettyConfiguration#sslContext(io.netty.handler.ssl.SslContext)}
918914
* instead.
919915
*
920-
* @see NioParams#enableHostnameVerification()
921-
* @see NioParams#setSslEngineConfigurator(SslEngineConfigurator)
922-
* @see SslEngineConfigurators#ENABLE_HOSTNAME_VERIFICATION
923916
* @see SocketConfigurators#ENABLE_HOSTNAME_VERIFICATION
924917
* @see ConnectionFactory#useSslProtocol(String)
925918
* @see ConnectionFactory#useSslProtocol(SSLContext)
@@ -928,18 +921,10 @@ public ConnectionFactory useSslProtocol(SSLContext context) {
928921
* @since 5.4.0
929922
*/
930923
public ConnectionFactory enableHostnameVerification() {
931-
enableHostnameVerificationForNio();
932924
enableHostnameVerificationForBlockingIo();
933925
return this;
934926
}
935927

936-
protected void enableHostnameVerificationForNio() {
937-
if (this.nioParams == null) {
938-
this.nioParams = new NioParams();
939-
}
940-
this.nioParams = this.nioParams.enableHostnameVerification();
941-
}
942-
943928
protected void enableHostnameVerificationForBlockingIo() {
944929
if (this.socketConf == null) {
945930
this.socketConf =
@@ -1076,21 +1061,7 @@ public ConnectionFactory setCredentialsRefreshService(
10761061
}
10771062

10781063
protected synchronized FrameHandlerFactory createFrameHandlerFactory() throws IOException {
1079-
if (nio) {
1080-
if (this.frameHandlerFactory == null) {
1081-
if (this.nioParams.getNioExecutor() == null && this.nioParams.getThreadFactory() == null) {
1082-
this.nioParams.setThreadFactory(getThreadFactory());
1083-
}
1084-
this.frameHandlerFactory =
1085-
new SocketChannelFrameHandlerFactory(
1086-
connectionTimeout,
1087-
nioParams,
1088-
isSSL(),
1089-
sslContextFactory,
1090-
this.maxInboundMessageBodySize);
1091-
}
1092-
return this.frameHandlerFactory;
1093-
} else if (netty) {
1064+
if (netty) {
10941065
if (this.frameHandlerFactory == null) {
10951066
this.frameHandlerFactory =
10961067
new NettyFrameHandlerFactory(
@@ -1659,59 +1630,11 @@ public ConnectionFactory setRecoveryDelayHandler(
16591630
return this;
16601631
}
16611632

1662-
/**
1663-
* Sets the parameters when using NIO.
1664-
*
1665-
* @param nioParams
1666-
* @see NioParams
1667-
* @deprecated user {@link #netty()} instead
1668-
*/
1669-
@Deprecated
1670-
public ConnectionFactory setNioParams(NioParams nioParams) {
1671-
this.nioParams = nioParams;
1672-
return this;
1673-
}
1674-
1675-
/**
1676-
* Retrieve the parameters for NIO mode.
1677-
*
1678-
* @return
1679-
* @deprecated Use {@link #netty()}
1680-
*/
1681-
@Deprecated
1682-
public NioParams getNioParams() {
1683-
return nioParams;
1684-
}
1685-
1686-
/**
1687-
* Use non-blocking IO (NIO) for communication with the server. With NIO, several connections
1688-
* created from the same {@link ConnectionFactory} can use the same IO thread.
1689-
*
1690-
* <p>A client process using a lot of not-so-active connections can benefit from NIO, as it would
1691-
* use fewer threads than with the traditional, blocking IO mode.
1692-
*
1693-
* <p>Use {@link NioParams} to tune NIO and a {@link SocketChannelConfigurator} to configure the
1694-
* underlying {@link java.nio.channels.SocketChannel}s for connections.
1695-
*
1696-
* @see NioParams
1697-
* @see SocketChannelConfigurator
1698-
* @see java.nio.channels.SocketChannel
1699-
* @see java.nio.channels.Selector
1700-
* @deprecated Use {@link #netty()} instead
1701-
*/
1702-
@Deprecated
1703-
public ConnectionFactory useNio() {
1704-
this.nio = true;
1705-
this.netty = false;
1706-
return this;
1707-
}
1708-
17091633
/**
17101634
* Use blocking IO for communication with the server. With blocking IO, each connection creates
17111635
* its own thread to read data from the server.
17121636
*/
17131637
public ConnectionFactory useBlockingIo() {
1714-
this.nio = false;
17151638
this.netty = false;
17161639
return this;
17171640
}
@@ -1885,7 +1808,6 @@ public ConnectionFactory setTrafficListener(TrafficListener trafficListener) {
18851808

18861809
private ConnectionFactory useNetty() {
18871810
this.netty = true;
1888-
this.nio = false;
18891811
return this;
18901812
}
18911813

src/main/java/com/rabbitmq/client/ConnectionFactoryConfigurator.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
1+
// Copyright (c) 2017-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
22
//
33
// This software, the RabbitMQ Java client library, is triple-licensed under the
44
// Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2
@@ -16,7 +16,6 @@
1616
package com.rabbitmq.client;
1717

1818
import com.rabbitmq.client.impl.AMQConnection;
19-
import com.rabbitmq.client.impl.nio.NioParams;
2019

2120
import javax.net.ssl.*;
2221
import java.io.FileInputStream;
@@ -69,12 +68,6 @@ public class ConnectionFactoryConfigurator {
6968
public static final String CONNECTION_RECOVERY_INTERVAL = "connection.recovery.interval";
7069
public static final String CHANNEL_RPC_TIMEOUT = "channel.rpc.timeout";
7170
public static final String CHANNEL_SHOULD_CHECK_RPC_RESPONSE_TYPE = "channel.should.check.rpc.response.type";
72-
public static final String USE_NIO = "use.nio";
73-
public static final String NIO_READ_BYTE_BUFFER_SIZE = "nio.read.byte.buffer.size";
74-
public static final String NIO_WRITE_BYTE_BUFFER_SIZE = "nio.write.byte.buffer.size";
75-
public static final String NIO_NB_IO_THREADS = "nio.nb.io.threads";
76-
public static final String NIO_WRITE_ENQUEUING_TIMEOUT_IN_MS = "nio.write.enqueuing.timeout.in.ms";
77-
public static final String NIO_WRITE_QUEUE_CAPACITY = "nio.write.queue.capacity";
7871
public static final String SSL_ALGORITHM = "ssl.algorithm";
7972
public static final String SSL_ENABLED = "ssl.enabled";
8073
public static final String SSL_KEY_STORE = "ssl.key.store";
@@ -225,35 +218,6 @@ public static void load(ConnectionFactory cf, Map<String, String> properties, St
225218
cf.setChannelShouldCheckRpcResponseType(Boolean.valueOf(channelShouldCheckRpcResponseType));
226219
}
227220

228-
String useNio = lookUp(USE_NIO, properties, prefix);
229-
if (useNio != null && Boolean.valueOf(useNio)) {
230-
cf.useNio();
231-
232-
NioParams nioParams = new NioParams();
233-
234-
String readByteBufferSize = lookUp(NIO_READ_BYTE_BUFFER_SIZE, properties, prefix);
235-
if (readByteBufferSize != null) {
236-
nioParams.setReadByteBufferSize(Integer.valueOf(readByteBufferSize));
237-
}
238-
String writeByteBufferSize = lookUp(NIO_WRITE_BYTE_BUFFER_SIZE, properties, prefix);
239-
if (writeByteBufferSize != null) {
240-
nioParams.setWriteByteBufferSize(Integer.valueOf(writeByteBufferSize));
241-
}
242-
String nbIoThreads = lookUp(NIO_NB_IO_THREADS, properties, prefix);
243-
if (nbIoThreads != null) {
244-
nioParams.setNbIoThreads(Integer.valueOf(nbIoThreads));
245-
}
246-
String writeEnqueuingTime = lookUp(NIO_WRITE_ENQUEUING_TIMEOUT_IN_MS, properties, prefix);
247-
if (writeEnqueuingTime != null) {
248-
nioParams.setWriteEnqueuingTimeoutInMs(Integer.valueOf(writeEnqueuingTime));
249-
}
250-
String writeQueueCapacity = lookUp(NIO_WRITE_QUEUE_CAPACITY, properties, prefix);
251-
if (writeQueueCapacity != null) {
252-
nioParams.setWriteQueueCapacity(Integer.valueOf(writeQueueCapacity));
253-
}
254-
cf.setNioParams(nioParams);
255-
}
256-
257221
String useSsl = lookUp(SSL_ENABLED, properties, prefix);
258222
if (useSsl != null && Boolean.valueOf(useSsl)) {
259223
setUpSsl(cf, properties, prefix);

src/main/java/com/rabbitmq/client/DefaultSocketChannelConfigurator.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/main/java/com/rabbitmq/client/SocketChannelConfigurator.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)