@Override
public void onReceive(Object message) throws Exception {
if (message instanceof TransferMsg) {
final TransferMsg transfer = (TransferMsg) message;
final Coordinated coordinated = new Coordinated(timeout);
coordinated.atomic(new Runnable() {
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) {