How to create shard region with roles and communicate different role of the shard region


I am creating shard region by using the below settings.

ClusterShardingSettings settings = ClusterShardingSettings.create(actorSystem).withRole(role);

I have two roles ex, role1 and role2. I want to allocate 3 actor System for role 1 and two for role2 to create actors in a distribute fashion.

And also I want to communicate message between different roles of the shard region.

Could you please help me to achieve this usecae


The role setting on sharding determines which nodes to run shards on, on nodes that doesn’t have that role you can use the shard proxy to interact with the sharded actors, see the docs here: