2011-12-21 21:32:20 +13:00
|
|
|
/**
|
2012-01-19 18:21:06 +01:00
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
2011-12-21 21:32:20 +13:00
|
|
|
*/
|
|
|
|
|
|
2012-05-22 11:37:09 +02:00
|
|
|
package docs.transactor;
|
2011-12-21 21:32:20 +13:00
|
|
|
|
|
|
|
|
import akka.actor.*;
|
|
|
|
|
import akka.transactor.*;
|
|
|
|
|
|
|
|
|
|
public class Coordinator extends UntypedActor {
|
|
|
|
|
public void onReceive(Object incoming) throws Exception {
|
|
|
|
|
if (incoming instanceof Coordinated) {
|
|
|
|
|
Coordinated coordinated = (Coordinated) incoming;
|
|
|
|
|
Object message = coordinated.getMessage();
|
|
|
|
|
if (message instanceof Message) {
|
|
|
|
|
//#coordinated-atomic
|
2012-01-18 15:59:59 +13:00
|
|
|
coordinated.atomic(new Runnable() {
|
|
|
|
|
public void run() {
|
2011-12-21 21:32:20 +13:00
|
|
|
// do something in the coordinated transaction ...
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//#coordinated-atomic
|
|
|
|
|
}
|
2011-12-29 20:49:26 +01:00
|
|
|
} else {
|
|
|
|
|
unhandled(incoming);
|
2011-12-21 21:32:20 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|