akka.patterns.ask everywhere
This commit is contained in:
parent
a342bb93ea
commit
ce1d2f4721
53 changed files with 78 additions and 27 deletions
|
|
@ -13,7 +13,7 @@ import akka.actor.Props;
|
|||
import akka.actor.Terminated;
|
||||
import akka.actor.UntypedActor;
|
||||
import akka.dispatch.Await;
|
||||
import static akka.dispatch.Futures.ask;
|
||||
import static akka.Patterns.ask;
|
||||
import akka.util.Duration;
|
||||
import akka.testkit.AkkaSpec;
|
||||
import akka.testkit.TestProbe;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.junit.Test;
|
|||
import scala.Option;
|
||||
import java.lang.Object;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import akka.Patterns;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
@ -118,7 +119,7 @@ public class UntypedActorDocTestBase {
|
|||
}), "myactor");
|
||||
|
||||
//#using-ask
|
||||
Future<Object> future = Futures.ask(myActor, "Hello", 1000);
|
||||
Future<Object> future = Patterns.ask(myActor, "Hello", 1000);
|
||||
Object result = Await.result(future, Duration.create(1, TimeUnit.SECONDS));
|
||||
//#using-ask
|
||||
system.shutdown();
|
||||
|
|
@ -170,7 +171,7 @@ public class UntypedActorDocTestBase {
|
|||
public void useWatch() {
|
||||
ActorSystem system = ActorSystem.create("MySystem");
|
||||
ActorRef myActor = system.actorOf(new Props(WatchActor.class));
|
||||
Future<Object> future = myActor.ask("kill", 1000);
|
||||
Future<Object> future = Patterns.ask(myActor, "kill", 1000);
|
||||
assert Await.result(future, Duration.parse("1 second")).equals("finished");
|
||||
system.shutdown();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import akka.actor.UntypedActor;
|
|||
import akka.actor.ActorRef;
|
||||
import akka.actor.Props;
|
||||
import akka.dispatch.Futures;
|
||||
import akka.Patterns;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ public class FutureDocTestBase {
|
|||
String msg = "hello";
|
||||
//#ask-blocking
|
||||
Timeout timeout = system.settings().ActorTimeout();
|
||||
Future<Object> future = Futures.ask(actor, msg, timeout);
|
||||
Future<Object> future = Patterns.ask(actor, msg, timeout);
|
||||
String result = (String) Await.result(future, timeout.duration());
|
||||
//#ask-blocking
|
||||
assertEquals("HELLO", result);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.junit.Test;
|
|||
//#imports
|
||||
import akka.actor.*;
|
||||
import akka.dispatch.Await;
|
||||
import static akka.dispatch.Futures.ask;
|
||||
import static akka.Patterns.ask;
|
||||
import akka.transactor.Coordinated;
|
||||
import akka.util.Duration;
|
||||
import akka.util.Timeout;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue