Package org.akka.essentials.stm.transactor.example.msg

Examples of org.akka.essentials.stm.transactor.example.msg.AccountDebit


      Coordinated coordinated = (Coordinated) o;
      final Object message = coordinated.getMessage();
      if (message instanceof AccountDebit) {
        coordinated.atomic(new Runnable() {
          public void run() {
            AccountDebit accDebit = (AccountDebit) message;
            //check for funds availability
            if (balance.get() > accDebit.getAmount()) {
              float bal = balance.get() - accDebit.getAmount();
              balance.set(bal);
            } else {
              throw new IllegalStateException(
                  "Insufficient Balance");
            }
View Full Code Here


        public void run() {
          // credit amount - will always be successful
          to.tell(coordinated.coordinate(new AccountCredit(transfer
              .getAmtToBeTransferred())));
          // debit amount - throws an exception if funds insufficient
          from.tell(coordinated.coordinate(new AccountDebit(transfer
              .getAmtToBeTransferred())));
        }
      });
    } else if (message instanceof AccountBalance) {
View Full Code Here

TOP

Related Classes of org.akka.essentials.stm.transactor.example.msg.AccountDebit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.