Hello Pavel,

It seems to me that you’re overdoing a lot inside that implementation.
I don’t really see what gain your own deliveryIds is meant to provide.

Let’s take a step back and look at the semantics of deliver and
confirmDelivery *during playback*.
During normal operation I think it’s clear how they work. However, when
recovery is running, and you call deliver(msg) it delays the sending until
recovery is complete:
​

def deliver(destination: ActorPath, deliveryIdToMessage: Long ⇒ Any): Unit = {
  // -- cut cut cut --
  if (recoveryRunning)
    unconfirmed = unconfirmed.updated(deliveryId, d)
  else    send(deliveryId, d, now)
}

So during replay you encounter confirmation events, and trigger
confirmDelivery, which removes the delivery from unconfirmed.
This means that unconfirmed will not be sent again - it was already
confirmed.
All other outstanding messages will be redelivered again - as expected.

And now as for pruning the actor’s event log:
All you need to track is one number - the (persistent) seqNr of the last
confirmed delivery (there are caveats to this, read on) - you can get it
via lastSequenceNr.

Please note that if you send messages to multiple destinations, one
destination could reply with 5 while the other didn’t reply to 4 yet.
So when updating this “safe to delete until” number, you must check that
it’s gap-less, or you’d delete a persistent message resulting in an emit of
an yet unconfirmed message send.
But if these are gap-less, you can issue an deleteMessages(toSequenceNr =
safeToDeleteUntilHereInclusive).

Again, I don’t think you need to track delivery ids like you are in your
example - that is exacly what AtLeastOnceDelivery does.
And your replay code can be simplified - to simply call deliver /
confirmDelivery during replay, and this will not result in not needed
message sends.

I hope this helps, if not let me know and we’ll investigate in more detail
:-)
​



-- 
Cheers,
Konrad 'ktoso' Malawski
hAkker @ Typesafe

<http://typesafe.com>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to