Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka Java : create an actor with constructor taking parameters

Tags:

java

akka

How could i create an actor with a customized constructor in java ? I have searched through the documentation but didn't found 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 have tried this :

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

But it doesn't work.

Thank you

like image 244
Master Mind Avatar asked May 06 '15 12:05

Master Mind


1 Answers

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

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

like image 112
Infinity Avatar answered Oct 30 '22 04:10

Infinity