Skip to content
Paweł Kaczor edited this page Nov 2, 2016 · 13 revisions

Reliable Delivery between event-sourced actors

To support the At-Least-Once delivery semantics (which is the ground for the reliable delivery) the sender should mix in the AtLeastOnceDelivery trait.

The At-Least-Once delivery implies that the original message send order is not always retained and the destination may receive duplicate messages due to possible resends.

Deduplication

As long as the actions, that the receiver takes to process the messages, are idempotent, the duplicate messages are not a problem. Otherwise the receiver should obtain the identifier of the received message and attach it to the event message (as a CausationID meta-attribute) that gets written to the receiver journal. The receiver should recognize an incoming message as a duplicate by checking if its ID is one of those IDs collected in the past. Obviously, the duplicate message should not be processed by the receiver. Still, the acknowledgment (delivery receipt) should be sent to the sender.

Akka-DDD provides the Deduplication trait that implements the logic of the deduplication as described above. The trait is mixed in by Aggregate Root and Process Manager.

Akka-DDD guarantees that the message is not processed twice by the Aggregate Root or Process Manager.

Rejecting out-of-order messages

Receptor --> Process Manager

The sender should maintain the lastSentMsgIdPerReceiver map (of type: Map[EntityId, String]) as part of its DeliveryInProgressState. Using this map, when sending a message to a receiver, the sender should obtain the ID of the last message that was sent to the receiver, and attach it to the message being sent as the MustFollow meta-attribute. Assuming, the receiver knows the IDs of the messages received/processed in the past (see: Deduplication), it should recognize an incoming message as an out-of-order, if no message was received/processed in the past whose ID was equal to the value of the MustFollow meta-attribute of the incoming message.

Akka-DDD guarantees that events are propagated to the Process Managers in the order they were stored in the source journals.

Process Manager --> Aggregate Root

Clone this wiki locally