Akka Java: create an actor with a constructor parameter that takes parameters

How can I create an actor with a custom constructor in java? I looked through the documentation but did not find it.

Here is my actor:

public class ResizePhotoActor extends UntypedActor { private int width; private int height; private String caption; public ResizePhotoActor(int width, int height, String caption) { this.height = height; this.width = width; this.caption = caption; } public void onReceive(Object message) throws Exception { } } 

I tried this:

  ActorRef imageActorRef = system.actorOf( Props.create(new ResizePhotoActor(1, 2, ""))); 

But that will not work.

thanks

+5
source share
1 answer
 ActorRef imageActorRef = system.actorOf(Props.create(ResizePhotoActor.class, 1, 2, "")); 

Docs: http://doc.akka.io/docs/akka/current/java/actors.html#Props

+14
source

All Articles