I'm trying to implement a custom mailbox according to the guidelines at
http://doc.akka.io/docs/akka/snapshot/java/mailboxes.html for our akka application (akka 2.2.3), creating a marker "Semantics" interface, and having my actor implementing the RequiresMessageQueue<MyQueueSemantics>. This works perfectly fine, except when running our unit tests, which are using Akka Testkit, in which case it produces an exception. The error we are getting is:
java.lang.NullPointerException
at akka.actor.dungeon.Dispatch$class.init(Dispatch.scala:62)
at akka.actor.ActorCell.init(ActorCell.scala:338)
at akka.actor.LocalActorRef.<init>(ActorRef.scala:304)
at akka.testkit.TestActorRef.<init>(TestActorRef.scala:21)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:141)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:137)
at akka.testkit.TestActorRef$.create(TestActorRef.scala:160)
at akka.testkit.TestActorRef.create(TestActorRef.scala)
s"Actor [$self] requires mailbox type [$req] got [${mbox.messageQueue.getClass.getName}]")))
I assume it means that mbox.messageQueue is found to be null. As mentioned, the code runs fine, except when using the testing framework. Is there anything in particular that need to be done to use a custom mailbox implementation this way in our tests? If we configure the mailbox in our application.conf instead, for our dispatcher, everything works fine, both normally and with our tests.
Nils-H