diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index cbb3d4f38cc..052f43e3b26 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -92,6 +92,10 @@ akka { # (I) Reuse inbound connections for outbound messages use-passive-connections = on + # (I) If "on" then the default dispatcher will be used to accept inbound connections, + # and IO. If "off" then dedicated threads will be used. + use-default-dispatcher-for-io = off + # (I) The hostname or ip to bind the remoting to, # InetAddress.getLocalHost.getHostAddress is used if empty hostname = "" diff --git a/akka-remote/src/main/scala/akka/remote/netty/Server.scala b/akka-remote/src/main/scala/akka/remote/netty/Server.scala index 1f18b27c8c2..c20c1cba355 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/Server.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/Server.scala @@ -26,9 +26,10 @@ class NettyRemoteServer(val netty: NettyRemoteTransport) { val ip = InetAddress.getByName(settings.Hostname) - private val factory = new NioServerSocketChannelFactory( - Executors.newCachedThreadPool(netty.system.threadFactory), - Executors.newCachedThreadPool(netty.system.threadFactory)) + private val factory = { + val boss, worker = if (settings.UseDefaultDispatcherForIO) netty.system.dispatcher else Executors.newCachedThreadPool() + new NioServerSocketChannelFactory(boss, worker) + } private val executionHandler = new ExecutionHandler(netty.executor) diff --git a/akka-remote/src/main/scala/akka/remote/netty/Settings.scala b/akka-remote/src/main/scala/akka/remote/netty/Settings.scala index 2bb441dc3c4..e12da190bc8 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/Settings.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/Settings.scala @@ -27,6 +27,7 @@ class NettySettings(config: Config, val systemName: String) { } val UsePassiveConnections = getBoolean("use-passive-connections") + val UseDefaultDispatcherForIO = getBoolean("use-default-dispatcher-for-io") val ReconnectionTimeWindow = Duration(getMilliseconds("reconnection-time-window"), MILLISECONDS) val ReadTimeout = Duration(getMilliseconds("read-timeout"), MILLISECONDS)