How to use the Akka event stream correctly?

I use the Akka event stream in the Play application as an event bus, where I can publish events and subscribe to listeners, and I would like to know what errors should be taken into account. In particular, there are two things:

  • Each listener is realized through an actor who receives published events and processes them. What if the actor’s message queue starts to get large? How can I safely implement back pressure, ensuring that every event is ultimately handled?
  • Related to the previous: how can I transfer unprocessed events, so in case of failure the application can start again and process them? I know about the existence of akka-persistence, but I'm not sure that would be correct in this case: Listener actors are not restrained, they do not need to replay past events, I just want to save the unprocessed events and delete them after they are processed.
+6
source share
1 answer

Given the limitations, I would not use the Akka event bus for this purpose.

Main reasons:

  • Delivery . You have no guarantee that event listeners are actually listening (no ACK). It is possible to lose some events along the way.
  • Sustainability . There is no built-in way to save the status of the event bus.
  • Scaling - the Akka event bus is a local facility, which means that this is not suitable if you want to create a cluster in the future.

The easiest way to handle this is to use a message queue such as RabbitMQ. While back I used sstone / amqp-client . MQ can provide you with constant queues (a queue for each type of listener / listener).

+2
source

Source: https://habr.com/ru/post/987244/


All Articles