0

we need to create an Actor that discards messages once it's mailbox is filled up to a certain size. Browsing the assemblies reveiled that there is a BoundedMessageQueue already implemented offering the options:

  1. mailbox-capacity
  2. mailbox-push-timeout-time

We could not figure out the correct syntax how to create an actor with a BoundedMessageQueue and the appropriate settings. The closest we could get was Props.Create(...).WithMailbox(???)

Any help would be appriciated.

Xcessity
  • 529
  • 6
  • 12

1 Answers1

1

Use BoundedMailbox, which is backed by BoundedMessageQueue.

In your configuration (note that the mailbox needs to be defined outside of the akka namespace):

akka { ... }

bounded-mailbox {
    mailbox-capacity = 1000
    mailbox-push-timeout-time = 10s
    mailbox-type = "Akka.Dispatch.BoundedMailbox, Akka"
}

Then, to create an actor with this mailbox:

Props.Create<ActorType>().WithMailbox("bounded-mailbox");
Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54