Migration from netty to artery
Migrating from Netty to Artery involves several steps. Here are some key points to consider:
-
Artery is a reimplementation of the old remoting module (Netty) aimed at improving performance and stability. It is mostly source compatible with the old implementation and it is a drop-in replacement in many cases. However, the main incompatible change from the previous implementation is that the protocol field of the string representation of an ActorRef
is always akka instead of the previously used akka.tcp or akka.ssl.tcp. Configuration properties are also different. source
-
To enable Artery in your Akka project, you should add the following changes to your application.conf
file:
akka {
actor {
provider = cluster
}
remote {
artery {
transport = tcp
canonical.hostname = "127.0.0.1"
canonical.port = 25520
}
}
}
source
-
Rolling update from classic remoting to Artery is not supported since the protocol is completely different. It will require a full cluster shutdown and new startup. source
-
If you are migrating from classic remoting, you can refer to the migration guide provided by Akka. source
-
Deprecated Classic Remoting has been removed since Akka 2.8.x. Classic Remoting transport has been deprecated since Akka 2.6.0 and is replaced by the Artery transport, which has been the default since 2.6.0 and declared ready for production in Akka 2.5.22. source
Please note that while Artery is mostly source compatible with the old implementation, there are some differences and incompatibilities that you need to be aware of. Always refer to the official Akka documentation for the most accurate and up-to-date information.
Further, how should I replace akka.remote.netty.tcp.port
and akka.remote.netty.tcp.hostname
in my java code if I want to use artery?
If you want to replace akka.remote.netty.tcp.port
and akka.remote.netty.tcp.hostname
in your Java code to use Artery, you should use akka.remote.artery.canonical.port
and akka.remote.artery.canonical.hostname
instead.
Here is an example of how you can set them programmatically:
ConfigFactory.parseString("""
akka.remote.artery.canonical.port="25520"
akka.remote.artery.canonical.hostname="127.0.0.1"
""")
.withFallback(ConfigFactory.load());
This will set the port and hostname that Akka binds to for remoting. You can replace "25520"
and "127.0.0.1"
with the port and hostname you want to use.
source
And how does a process.conf file look?
A process.conf
file using Artery might look like this:
akka {
actor {
provider = "cluster"
}
remote {
artery {
enabled = on
transport = tcp
canonical {
hostname = "127.0.0.1"
port = 25520
}
}
}
}
In this configuration:
-
akka.actor.provider = "cluster"
specifies that the Actor provider should be a cluster. This is recommended over using remoting directly.
-
akka.remote.artery.enabled = on
enables Artery.
-
akka.remote.artery.transport = tcp
specifies that the transport protocol for Artery should be TCP.
-
akka.remote.artery.canonical.hostname = "127.0.0.1"
specifies the hostname that other nodes should use to connect to this node.
-
akka.remote.artery.canonical.port = 25520
specifies the port that other nodes should use to connect to this node.
Please note that the hostname and port should be set to values that are appropriate for your network configuration. source
I migrated from 2.5 to 2.6 and now i always get the error port already in use, but I don’t have any other process running in that port and am already using -Dakka.remote.artery.canonical.port=8000
If you’re certain that no other process is using the port and you’re still encountering the “port already in use” error, it could be due to a configuration issue or a problem with the system’s network settings.
Here are a few more things you can try:
-
Double-check your configuration to ensure that the akka.remote.artery.canonical.port
setting is correctly set to 8000
. Also, make sure that this setting is not being overridden somewhere else in your configuration.
-
Try restarting your system. Sometimes, ports can get stuck in a TIME_WAIT state, and restarting can help clear this state.
-
Check if there are any firewall or security group settings that might be preventing your application from binding to the port.
-
If you’re running your application in a container or a virtual machine, make sure that the port is correctly mapped or forwarded.
-
Try using a different port number to see if the problem is specific to port 8000
.
If none of these solutions work, it might be helpful to provide more information about your setup and the exact error message you’re seeing.
Finally, what is akka://ic?
The akka://ic
is an example of an Akka Actor System’s address. In this case, ic
is the name of the Actor System.
In Akka, every Actor System has a unique address which is used to identify it across all other Actor Systems (even on different machines). This address is used for remote communication between Actor Systems if it’s enabled.
The structure of an Actor System’s address is as follows:
-
It starts with akka://
which is the protocol field.
-
This is followed by the name of the Actor System, in this case ic
.
-
If remote communication is enabled, this part of the URL includes the hostname so other systems can find it on the network.
-
The path to a specific actor within the system would follow the system name. For example, /user/actorName
would point to an actor named actorName
under the user guardian.
-
The last part of the actor reference, such as #1053618476
or #-1544706041
, is a unique identifier that you can ignore in most cases.
Here is an example of an Actor System’s address: akka://ic/user/actorName#1053618476
.
Please note that the Actor System’s name (ic
in this case) should be unique for each Actor System on the same machine. source