0

We are using Akka with in-memory messages right now and no clustering of nodes. We use couchbase as our processing backend with plenty of space left.

Everything works fine as long as node is live. But when any node goes down, all in-memory messages are lost. We did reduce it by implementing "give me work" kind of design where worker actor asks for work when ideal and gets 500 messages in its queue. But those 500 are still in-memory.

Is there any way I can use couchbase as my queue for each mailbox? Older akka had durable mailbox but it is gone now. Persistent actor does not solve this problem.

Jags
  • 799
  • 7
  • 19

1 Answers1

0

What you can do is to create sort of a custom Mailbox implementation, and bind it to the appropriate actors/routers in the actor configuration. This is perfectly described in the official documentation, for example -

class MyPrioMailbox(settings: ActorSystem.Settings, config: Config)
  extends UnboundedStablePriorityMailbox(
   // Create a new PriorityGenerator, lower prio means more important
   PriorityGenerator {
     // 'highpriority messages should be treated first if possible
     case 'highpriority => 0

     // 'lowpriority messages should be treated last if possible
     case 'lowpriority  => 2

     // PoisonPill when no other left
     case PoisonPill    => 3

     // We default to 1, which is in between high and low
     case otherwise     => 1
  })

Simply put, you create your own mailbox that is backed by the queue in couchbase, and you're done. Perhaps you need to figure out how to split the queue among the actors, and handle the actor restarts properly - but that is more related to the supervisor actor you're using.

jdevelop
  • 12,176
  • 10
  • 56
  • 112