Problem with Akka cluster aware Pool routers

Hi guys i have problem with Akka cluster aware routers, we have an routee actor with some constructor params , and one of the params is a java base RedisClient that is no serializable , and we we start the cluster get so many serialization errors for this actor deplyment in remote nodes ,

is there anyway to prevent actor constrcutor params from serialization and using some local instance of that params in remote deployment ?

object RouteeActor {

  def props(redisClient:RedisClient): Props =
    Props(new RouteeActor(redisClient))

  def apply(redisClient:RedisClient) = actorSystem.actorOf(
    props = FromConfig.props(RouteeActor.props(redisClient)),
    name = "eventRouter"
  )
}
Failed to serialize remote message [class akka.remote.DaemonMsgCreate] using serializer [class akka.remote.serialization.DaemonMsgCreateSerializer]. Transient association error (association remains live)
akka.actor.deployment {
  /eventRouter {
      router = consistent-hashing-pool
      cluster {
        enabled = on
        max-nr-of-instances-per-node = 3
        allow-local-routees = on
        use-roles = ["kenel"]
      }
    }
}

I’d recommend that you use a group router instead of a pool router for this. Then it will not serialize and remote deploy the routee actors. Also, consistent-hashing with pool router will probably not do what you expect since the routees are not shared for different sender nodes.

Thanks a lot Patrik for fast reply.

I tried the Group router by this config:

akka.actor.deployment {
  /eventRouter {
    router = cluster-metrics-adaptive-pool
    routees.paths = ["/routee"]
    cluster {
      enabled = on
      allow-local-routees = on
      use-roles = ["kenel"]
    }
  }
}
object RouteeActor {

  def props(redisClient:RedisClient): Props =
    Props(new RouteeActor(redisClient))

  def apply(redisClient:RedisClient) = actorSystem.actorOf(
    props = FromConfig.props(RouteeActor.props(redisClient)),
    name = "eventRouter"
  )
}

but get the same serialization errors.
In the other hand, it seems its a little slower than Pool Router as its on the ActorSelection !

That is still pool. cluster-metrics-adaptive-pool
Might need some more adjustments. Take a look at the documentation.

So Patrik one question,

I am trying to use Group router but maybe we will need to start actors ourselfs in all nodes and pass the paths to the router

Do we need to create all routees in all nodes ourself or FromConfig.props(Props(classOf[Worker],"worker")) will create routee actors also ?

For group routers you need to start the routees on each node and define the actor path of them in the router. I think the documentation has example of that in the group router section.
https://doc.akka.io/docs/akka/current/cluster-routing.html#router-with-group-of-routees