3

In an Akka Actor application, I have to postpone receiving certain types of messages after receiving a Control Message. For the sake of control messages, I had to implement my own priority Mailbox that prioritizes Control messages over ordinary messages. Let's assume this implementation works and cannot be undone. Mailbox looks like below with overridden enqueue and dequeue functions.

object MyControlAwareMailbox {
   class MyControlAwareMessageQueue extends MessageQueue with MyControlAwareMessageQueueSemantics {

      private final val controlQueue: Queue[Envelope] = new ConcurrentLinkedQueue[Envelope]()
      private final val queue: Queue[Envelope] = new ConcurrentLinkedQueue[Envelope]()

  }

my configuration file also looks like this:

custom-dispatcher {
   mailbox-requirement =
   "com.example.MyControlAwareMessageQueueSemantics"
}

akka.actor.mailbox.requirements {
  "com.example.MyControlAwareMessageQueueSemantics" =
   custom-dispatcher-mailbox
}

custom-dispatcher-mailbox {
   mailbox-type = "com.example.MyControlAwareMailbox"
}

akka.actor.mailbox.requirements {
   "akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = custom-dispatcher-mailbox
   "akka.dispatch.UnboundedMessageQueueSemantics" = custom-dispatcher-mailbox
}

akka.actor.default-mailbox {
   mailbox-type = "com.example.MyControlAwareMailbox"
}

is ther a way I can configure my app so that I can use akka stash for stashing messages?

13leak
  • 73
  • 9
  • Temporarily I put a stashing queue in my Actor class and handled stashing manually. I am not sure it's the only solution. – 13leak Jul 22 '20 at 14:18

0 Answers0