# Problem with Akka cluster aware Pool routers

**URL:** <https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011>\
**Category:** Akka Cluster\
**Tags:** akka-cluster\
**Created:** [August 7, 2020, 11:57am UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011 "2020-08-07T11:57:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hnourhani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hnourhani/32/1991_2.png) [@hnourhani](https://discuss.akka.io/u/hnourhani)\
**Post date:** [August 7, 2020, 11:57am UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/1 "2020-08-07T11:57:25Z")

</div>

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 ?

```auto
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"
  )
}

```

```auto
Failed to serialize remote message [class akka.remote.DaemonMsgCreate] using serializer [class akka.remote.serialization.DaemonMsgCreateSerializer]. Transient association error (association remains live)

```

```auto
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"]
      }
    }
}

```

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [August 7, 2020, 2:59pm UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/2 "2020-08-07T14:59:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hnourhani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hnourhani/32/1991_2.png) [@hnourhani](https://discuss.akka.io/u/hnourhani)\
**Post date:** [August 7, 2020, 3:52pm UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/3 "2020-08-07T15:52:48Z")

</div>

Thanks a lot Patrik for fast reply.

I tried the Group router by this config:

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

```

```auto
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 !

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [August 7, 2020, 6:01pm UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/4 "2020-08-07T18:01:59Z")

</div>

That is still pool. cluster-metrics-adaptive-pool  
Might need some more adjustments. Take a look at the [documentation](https://doc.akka.io/docs/akka/current/routing.html).

---

<div class="post-metadata">

**Author:** ![hnourhani](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hnourhani/32/1991_2.png) [@hnourhani](https://discuss.akka.io/u/hnourhani)\
**Post date:** [August 11, 2020, 2:59pm UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/5 "2020-08-11T14:59:24Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [August 15, 2020, 8:18am UTC](https://discuss.akka.io/t/problem-with-akka-cluster-aware-pool-routers/7011/6 "2020-08-15T08:18:10Z")

</div>

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](https://doc.akka.io/docs/akka/current/cluster-routing.html#router-with-group-of-routees)
