当我按照Akka文档在Akka actor中配置优先级邮箱时,它会抛出一个异常,说明邮箱未配置。
困难的部分是这个有时可以工作但是一旦我改变了与此无关的东西(只是注释和日志),然后重新打包它,它可能会抛出异常。这可能是由另一个重新打包和部署修复的。
这是我的application.conf:
akka {
prio-mailbox {
mailbox-type = "com.ea.tnt.pn.akka.actor.mailbox.AkkaPriorityMailBox"
//Other mailbox configuration goes here
}
// other stuff
}
}
邮箱:
公共类AkkaPriorityMailBox扩展了UnboundedPriorityMailbox {
public AkkaPriorityMailBox(ActorSystem.Settings settings, Config config) {
// Create a new PriorityGenerator, lower priority means more important
super(new PriorityGenerator() {
@Override
public int gen(Object message) {
//comparing algorithm
}
});
}
@Override
public Comparator<Envelope> cmp() {
return new Comparator<Envelope>() {
@Override
public int compare(Envelope t1, Envelope t2) {
//comparing algorithm
}
};
}
@Override
public int initialCapacity() {
return 10;
}
}
演员创作:
Props PPActorProps = Props.create(PPActor.class).withMailbox("akka.prio-mailbox");
ActorRef actor = getContext().actorOf(PPActorProps, "actor-name-" + i);
例外:
akka.ConfigurationException:使用调度程序[akka.actor.default-dispatcher]和邮箱[akka.prio-mailbox]创建XXXactor时的配置问题
引起:akka.ConfigurationException:未配置邮箱类型[akka.prio-mailbox] at akka.dispatch.Mailboxes.lookupConfigurator(Mailboxes.scala:189)〜[pn-backend.jar:na] at akka.dispatch.Mailboxes.lookup(Mailboxes.scala:78)〜[pn-backend.jar:na] at akka.dispatch.Mailboxes.getMailboxType(Mailboxes.scala:154)〜[pn-backend.jar:na] at akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:717)〜[pn-backend.jar:na] ...省略了16个常见帧