title: Is this a correct use case for an Akka role?
body: <p>I'm updating an Akka cluster where a particular actor should start on a node within the cluster depending on a configuration value. Initially, I considered using a custom Akka cluster role and have did some research, reading <a href="https://doc.akka.io/docs/akka/current/cluster-usage.html" rel="nofollow noreferrer">https://doc.akka.io/docs/akka/current/cluster-usage.html</a></p>
  <p>offers this code :</p>
  <pre><code>      void register(Member member) {
          if (member.hasRole(&quot;frontend&quot;))
            getContext()
                .actorSelection(member.address() + &quot;/user/frontend&quot;)
                .tell(BACKEND_REGISTRATION, getSelf());
        }
  
  So I could use something like : if (member.hasRole(&quot;&lt;MY_CUSTOM_ROLE&gt;&quot;)) {
      //Start My Actor
  }
  </code></pre>
  <p>Starting an actor depending on it's role does not appear to be the intended function of roles in Akka classic as in the example above the actor is not created. Instead a message is passed to another actor based on the path. As the spawn method is not available in Akka classic, creating an actor based on a role is not achievable for Akka classic?</p>
  <p>Akka typed for roles appears to achieve the expected functionality I'm trying to implement:</p>
  <p>From <a href="https://doc.akka.io/docs/akka/current/typed/cluster.html" rel="nofollow noreferrer">https://doc.akka.io/docs/akka/current/typed/cluster.html</a> :</p>
  <pre><code>Member selfMember = Cluster.get(context.getSystem()).selfMember();
  
  if (selfMember.hasRole(&quot;backend&quot;)) {
    context.spawn(Backend.create(), &quot;back&quot;);
  } else if (selfMember.hasRole(&quot;front&quot;)) {
    context.spawn(Frontend.create(), &quot;front&quot;);
  }
  </code></pre>
  <p>Here an Akka actor is created if the role is available.</p>
  <p>As I'm using classic Actors  I'm considering adding an environment variable instead of an Akka &quot;role&quot; for each deployment in the .yml file, then within the source code that starts all Akka actors if the environment variable is populated for the given deployment start the given actor, otherwise do not start the actor.
  Is this a viable solution for determining which actor should be started on each node within the cluster ?</p>