akka

transactor

package transactor

Visibility
  1. Public
  2. All

Type Members

  1. class Coordinated extends AnyRef

    Coordinated is a message wrapper that adds a CommitBarrier for explicitly coordinating transactions across actors or threads.

    Coordinated is a message wrapper that adds a CommitBarrier for explicitly coordinating transactions across actors or threads.

    Creating a Coordinated will create a commit barrier with initially one member. For each member in the coordination set a transaction is expected to be created using the coordinated atomic method, or the coordination cancelled using the cancel method.

    The number of included members must match the number of transactions, otherwise a successful transaction cannot be coordinated.

    To start a new coordinated transaction set that you will also participate in just create a Coordinated object:

    val coordinated = Coordinated()


    To start a coordinated transaction that you won't participate in yourself you can create a Coordinated object with a message and send it directly to an actor. The recipient of the message will be the first member of the coordination set:

    actor ! Coordinated(Message)


    To receive a coordinated message in an actor simply match it in a case statement:

    def receive = {
      case coordinated @ Coordinated(Message) => ...
    }


    To include another actor in the same coordinated transaction set that you've created or received, use the apply method on that object. This will increment the number of parties involved by one and create a new Coordinated object to be sent.

    actor ! coordinated(Message)


    To enter the coordinated transaction use the atomic method of the coordinated object:

    coordinated.atomic { implicit txn =>
      // do something in transaction ...
    }

    The coordinated transaction will wait for the other transactions before committing. If any of the coordinated transactions fail then they all fail.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

    See also

    akka.transactor.Transactor for an actor that implements coordinated transactions

  2. class CoordinatedTransactionException extends AkkaException

    Akka-specific exception for coordinated transactions.

    Akka-specific exception for coordinated transactions.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

  3. case class SendTo(actor: ActorRef, message: Option[Any] = None) extends Product with Serializable

    Used for specifying actor refs and messages to send to during coordination.

    Used for specifying actor refs and messages to send to during coordination.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

  4. trait Transactor extends Actor

    An actor with built-in support for coordinated transactions.

    An actor with built-in support for coordinated transactions.

    Transactors implement the general pattern for using akka.transactor.Coordinated where coordination messages are sent to other transactors then the coordinated transaction is entered. Transactors can also accept explicitly sent Coordinated messages.

    Simple transactors will just implement the atomically method which is similar to the actor receive method but runs within a coordinated transaction.

    Example of a simple transactor that will join a coordinated transaction:

    class Counter extends Transactor {
      val count = Ref(0)
    
      def atomically = implicit txn => {
        case Increment => count transform (_ + 1)
      }
    }


    To coordinate with other transactors override the coordinate method. The coordinate method maps a message to a set of akka.transactor.SendTo objects, pairs of ActorRef and a message. You can use the include and sendTo methods to easily coordinate with other transactors. The include method will send on the same message that was received to other transactors. The sendTo method allows you to specify both the actor to send to, and message to send.

    Example of coordinating an increment:

    class FriendlyCounter(friend: ActorRef) extends Transactor {
      val count = Ref(0)
    
      override def coordinate = {
        case Increment => include(friend)
      }
    
      def atomically = implicit txn => {
        case Increment => count transform (_ + 1)
      }
    }


    Using include to include more than one transactor:

    override def coordinate = {
      case Message => include(actor1, actor2, actor3)
    }


    Using sendTo to coordinate transactions but send on a different message than the one that was received:

    override def coordinate = {
      case Message => sendTo(someActor -> SomeOtherMessage)
      case SomeMessage => sendTo(actor1 -> Message1, actor2 -> Message2)
    }


    To execute directly before or after the coordinated transaction, override the before and after methods. These methods also expect partial functions like the receive method. They do not execute within the transaction.

    To completely bypass coordinated transactions override the normally method. Any message matched by normally will not be matched by the other methods, and will not be involved in coordinated transactions. In this method you can implement normal actor behavior, or use the normal STM atomic for local transactions.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

    See also

    akka.transactor.Coordinated

  5. class TransactorSettings extends Extension

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

  6. abstract class UntypedTransactor extends UntypedActor

    An UntypedActor version of transactor for using from Java.

    An UntypedActor version of transactor for using from Java.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

Deprecated Value Members

  1. object Coordinated

    Coordinated transactions across actors.

    Coordinated transactions across actors.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

  2. object TransactorExtension extends ExtensionId[TransactorSettings] with ExtensionIdProvider

    TransactorExtension is an Akka Extension to hold settings for transactors.

    TransactorExtension is an Akka Extension to hold settings for transactors.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.3) akka.transactor will be removed

Ungrouped