As per the below configuration Receptionist gets started eagerly when ActorSystem gets created.
But we have our own service discovery hence we do not use newly added receptionist. But as Receptionist extension is added, it tries to load ClusterReceptionist as soon as ActorSystem is created. Which require us to depend on akka-cluster-typed module which is unnecessary.
# Receptionist is started eagerly to allow clustered receptionist to gather remote registrations early on.
library-extensions += "akka.actor.typed.receptionist.Receptionist"
Hi! This configuration should only be loaded if you already have akka-actor-typed, and unless I’m missing something that should not require akka-cluster-typed. Are you sure you want akka-actor-typed? What kinds of errors are you getting when you remove the dependencies you want to avoid?
Yes, we are using akka-actor-typed and akka-cluster-tools with distributed data.
And if I do not add akka-cluster-typed dependency, I get ClassNotFoundException
[ERROR:akka] ClusterReceptionist could not be loaded dynamically. Make sure you have all required binaries on the classpath. [Stacktrace] java.lang.ClassNotFoundException: akka.cluster.typed.internal.receptionist.ClusterReceptionist$
I could see this in Receptionist
val ref: ActorRef[Receptionist.Command] = {
val behavior =
if (hasCluster)
system.dynamicAccess
.createInstanceFor[ReceptionistBehaviorProvider]("**akka.cluster.typed.internal.receptionist.ClusterReceptionist$**", Nil)
.recover {
case ex ⇒
system.log.error(
ex,
"ClusterReceptionist could not be loaded dynamically. Make sure you have all required binaries on the classpath.")
ReceptionistImpl
}.get.behavior
else ReceptionistImpl.localOnlyBehavior
ActorRef(
system.systemActorOf(behavior, "receptionist")(
// FIXME: where should that timeout be configured? Shouldn't there be a better `Extension`
// implementation that does this dance for us?
10.seconds))
}
This expect akka.cluster.typed.internal.receptionist.ClusterReceptionist$ in classpath which is coming from akka-cluster-typed
The Receptionist is central in how we intend Akka Typed to be used in a cluster setup moving forward, so I don’t think we will make that configurable. I’d recommend just adding the akka-cluster-typed dependency for now. For the long term, look at moving over to the Receptionist and let us know in what ways it falls short if it doesn’t solve problems you have solved with your own typed-cluster-service-discovery.