Akka Java:创建一个带有构造函数参数的演员



如何使用Java中的自定义构造函数创建一个演员?我已经搜索了文档,但没有找到它。

这是我的演员:

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 {

}
}

我尝试了以下方法:

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

但是它不起作用。

谢谢

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

文档:http://doc.akka.io/docs/akka/current/java/actors.html#props

最新更新