简体   繁体   中英

How to assign custom dispatcher in java-akka using parent actor context?

I created an actor system in java using akka, in the following way. Also I created the supervisor actor.

final ActorSystem system = getSystem(); system.actorOf(Props.create(Supervisor.class), Supervisor.NAME);

I updated the default dispatcher in the following way.

akka {
      default-dispatcher {
        # Dispatcher is the name of the event-based dispatcher
        type = Dispatcher
        # What kind of ExecutionService to use
        executor = "fork-join-executor"
        # Configuration for the fork join pool
        fork-join-executor {
          # Min number of threads to cap factor-based parallelism number to
          parallelism-min = 256
          # Parallelism (threads) ... ceil(available processors * factor)
          parallelism-factor = 40.0
          # Max number of threads to cap factor-based parallelism number to
          parallelism-max = 512
        }
        # Throughput defines the maximum number of messages to be
        # processed per actor before the thread jumps to the next actor.
        # Set to 1 for as fair as possible.
        throughput = 1
      }
}

The problem Im facing is when I write a custom dispatcher for a particular actor. In that it does not recognize the pattern of the actor

You need to add the "deployment" section to your config.

Code:

ActorRef myActor =
  system.actorOf(Props.create(MyActor.class),
    "myactor");

Config:

akka.actor.deployment {
  /myactor {
    dispatcher = my-dispatcher
  }
}

Look at the documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM