This is a post(set of questions really) regarding the implications of at-most-once(maybe-once) delivery reliability offered by akka on APIs and software based on akka. From my understanding, even messages sent by actors to self can be lost.
Till now, I have been in scenarios where delivery guarantee is not necessary, so life was good. But now, I need reliability from my service at least to the extent that the subscriber should know that a message has been lost. In trying to use akka streams and akka-http libraries, the following questions seemed important for me now.
- If messages can be lost in actor system, and akka-streams are based on actors, does that mean akka-streams are leaky? Thats pretty scary to think about. Specifically does a Flow(or GraphStage) ensure that stream entities are not lost?
For example, is the below code(based on Source.single doc) guaranteed to print
import akka.stream.*; CompletionStage<List<String>> future = Source.single("hello").runWith(Sink.seq(), materializer); CompletableFuture<List<String>> completableFuture = future.toCompletableFuture(); completableFuture.thenAccept(result -> System.out.println(result));
- If messages can be lost in actor system, and akka-http is based on actors, does that mean akka-http APIs, lets say websocket API randomly drops messages.
For example, in:
is it at least guaranteed that my flow will reliably receive everything on the websocket in order?
http.singleWebSocketRequest(WebSocketRequest.create("wss://api.example.com"), flow, mat)
- In actor world, I would have a sequence number on each message and let the receiver actor take remedial measures on a lost(probably never because of at-most-once reliability issues) sequence number. In case we live in a dystopian world where the answers to 1. and 2. are yes, this wouldn’t work because the external web service I consume does not implement sequence numbers. Because any sequence number I generate within the application will only add sequence numbers to messages that are not already lost. Is this a correct understanding?