akka.transactor

Coordinated

class Coordinated extends AnyRef

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.

See also

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

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Coordinated
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Coordinated(timeout: Timeout)

  2. new Coordinated(message: Any, timeout: Timeout)

  3. new Coordinated(message: Any, member: Member)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def apply(msg: Any): Coordinated

    Create a new Coordinated object and increment the number of members by one.

    Create a new Coordinated object and increment the number of members by one. Use this method to pass on the coordination.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def atomic[A](callable: Callable[A]): A

    Java API: coordinated atomic method that accepts a java.util.concurrent.Callable.

    Java API: coordinated atomic method that accepts a java.util.concurrent.Callable. Delimits the coordinated transaction. The transaction will wait for all other transactions in this coordination before committing. The timeout is specified when creating the Coordinated.

    Exceptions thrown
    CoordinatedTransactionException

    if the coordinated transaction fails.

  9. def atomic(runnable: Runnable): Unit

    Java API: coordinated atomic method that accepts a java.lang.Runnable.

    Java API: coordinated atomic method that accepts a java.lang.Runnable. Delimits the coordinated transaction. The transaction will wait for all other transactions in this coordination before committing. The timeout is specified when creating the Coordinated.

    Exceptions thrown
    CoordinatedTransactionException

    if the coordinated transaction fails.

  10. def atomic[A](body: (InTxn) ⇒ A): A

    Delimits the coordinated transaction.

    Delimits the coordinated transaction. The transaction will wait for all other transactions in this coordination before committing. The timeout is specified when creating the Coordinated.

    Exceptions thrown
    CoordinatedTransactionException

    if the coordinated transaction fails.

  11. def await(): Unit

    An empty coordinated atomic block.

    An empty coordinated atomic block. Can be used to complete the number of members involved and wait for all transactions to complete.

  12. def cancel(info: Any): Unit

    Cancel this Coordinated transaction.

  13. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. def coordinate(msg: Any): Coordinated

    Java API: create a new Coordinated object and increment the number of members by one.

    Java API: create a new Coordinated object and increment the number of members by one. Use this method to pass on the coordination.

  15. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  19. def getMessage(): Any

    Java API: get the message for this Coordinated.

  20. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. val message: Any

  23. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. def noIncrement(msg: Any): Coordinated

    Create a new Coordinated object but *do not* increment the number of members by one.

    Create a new Coordinated object but *do not* increment the number of members by one. Only use this method if you know this is what you need.

  25. final def notify(): Unit

    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  28. def toString(): String

    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  30. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  31. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any