AKKA:无法使用自定义邮箱配置

时间:2016-04-02 01:13:08

标签: akka

我是akka的新手并试图做以下简单的例子:

   public static void main(String[] args){
        Config cf = ConfigFactory.parseString(" bounded-mailbox {\n"
            + "  mailbox-type = \"akka.dispatch.NonBlockingBoundedMailbox\"\n"
            + "  mailbox-capacity = 1000\n"
            + "}");
        ActorSystem system = ActorSystem.create("MySystem", cf); ActorRef                  
        myActor = system.actorOf(Props.create(MyActor.class).withMailbox("bounded-mailbox"), "myactor");
        for(int index = 0; index<=100; index++) {
            myActor.tell(index, myActor.noSender());
        }
        try {
            Thread.sleep(120000);
        }catch (Exception exc){}
   }

MyActor.class - 是一个简单的actor类,用于打印收到的消息。

运行时出现以下错误:

Caused by: java.lang.IllegalArgumentException: Cannot instantiate MailboxType [akka.dispatch.NonBlockingBoundedMailbox], defined in [bounded-mailbox], make sure it has a public constructor with [akka.actor.ActorSystem.Settings, com.typesafe.config.Config] parameters
    at akka.dispatch.Mailboxes$$anonfun$1.applyOrElse(Mailboxes.scala:197)
    at akka.dispatch.Mailboxes$$anonfun$1.applyOrElse(Mailboxes.scala:195)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
    at scala.util.Failure$$anonfun$recover$1.apply(Try.scala:185)
    at scala.util.Try$.apply(Try.scala:161)
    at scala.util.Failure.recover(Try.scala:185)
    at akka.dispatch.Mailboxes.lookupConfigurator(Mailboxes.scala:195)
    at akka.dispatch.Mailboxes.lookup(Mailboxes.scala:78)
    at akka.dispatch.Mailboxes.getMailboxType(Mailboxes.scala:154)
    at akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:717)
    ... 10 more

任何想法?我正在使用akka-actor_2.10-2.3.7

1 个答案:

答案 0 :(得分:0)

In [2]: f.instance_method(1, 2, 3)
instance method 1 2 3

In [3]: f.static_make(1, 2, 3)
static make 1 2 3

In [4]: Fritz.static_make(1, 2, 3)
static make 1 2 3

In [5]: Fritz.instance_method(1, 2, 3, 4)
instance method 2 3 4

我认为您的脚本应更改为

mailbox-type = \"akka.dispatch.NonBlockingBoundedMailbox\"\n"