Package

eu.shiftforward.apso

actor

Permalink

package actor

Visibility
  1. Public
  2. All

Type Members

  1. abstract class Retrier[Req, Msg, Ack, Key] extends AnyRef

    Permalink

    Helper class for actors that need to retry some of the messages they send to other actors until a certain acknowledgement message (ACK) is received.

    Helper class for actors that need to retry some of the messages they send to other actors until a certain acknowledgement message (ACK) is received. Messages can be sent individually or in batches.

    This class is instantiated by providing functions that extract an identifier from sent messages and from ACK messages. This can be an arbitrary identifier, as long as it uniquely associates a received ACK with the original sent message. Optional per-message filtering functions can be given, as well as the frequency of the retries and an optional timeout. Finally, the onComplete method, which is executed after a message or group of messages is acknowledged, must be implemented.

    A Retrier can be used as follows:

    case class ChangeData(reqId: Long, data: String)
    case class ChangeDataAck(reqId: Long)
    case class Replicate(reqId: Long, data: String)
    case class ReplicateAck(reqId: Long)
    
    class Master(val replica: ActorRef) extends Actor {
      import Retrier._
    
      val retrier = new Retrier[(ActorRef, ChangeData), Replicate, ReplicateAck, Long](_.reqId, _.reqId) {
        def onComplete(req: (ActorRef, ChangeData)) = req._1 ! ChangeDataAck(req._2.reqId)
      }
    
      def receive: Receive = ({
        case msg @ ChangeData(reqId, data) =>
          // change data internally here
          retrier.dispatch((sender, msg), Replicate(reqId, data), replica)
    
      }: Receive).orRetryWith(retrier)
    }

    In the previous example, every time a Master actor receives a ChangeData message, it sends a Replicate message to a replica actor and only responds to the original sender after an acknowledgement from the replica is received. The Replicate message is retried periodically.

    Req

    the type of the triggering request

    Msg

    the type of the messages to be sent and retried

    Ack

    the type of the ACK messages

    Key

    the type of identifier or object that links a sent message to its ACK

    Annotations
    @deprecated
    Deprecated

    (Since version 2017/07/13) This will be removed in a future version

Deprecated Value Members

  1. object Retrier

    Permalink

    Companion object for Retrier, containing extension methods for actor Receive actions.

    Companion object for Retrier, containing extension methods for actor Receive actions.

    Annotations
    @deprecated
    Deprecated

    (Since version 2017/07/13) This will be removed in a future version

Ungrouped