Skip to content

Commit 641c7d7

Browse files
committed
Correct api for call actors
1 parent d26684d commit 641c7d7

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,12 @@ To invoke an actor named like the one we defined in section [Getting Started](#g
833833
```Java
834834
ActorRef joeActor = spawnSystem.createActorRef("spawn-system", "joe");
835835

836-
Domain.Request msg = Domain.Request.newBuilder()
837-
.setLanguage("erlang")
838-
.build();
839-
Domain.Reply reply =
840-
(Domain.Reply) joeActor.invoke("setLanguage", msg, Domain.Reply.class);
836+
Domain.Request msg = Domain.Request.newBuilder()
837+
.setLanguage("erlang")
838+
.build();
839+
840+
Optional<Object> maybeResponse = joeActor.invoke("setLanguage", msg, Domain.Reply.class);
841+
Domain.Reply reply = (Domain.Reply)maybeResponse.get();
841842
```
842843

843844
More detailed in complete main class:
@@ -871,8 +872,9 @@ public class App {
871872
Domain.Request msg = Domain.Request.newBuilder()
872873
.setLanguage("erlang")
873874
.build();
874-
Domain.Reply reply =
875-
(Domain.Reply) joeActor.invoke("setLanguage", msg, Domain.Reply.class);
875+
876+
Optional<Object> maybeResponse = joeActor.invoke("setLanguage", msg, Domain.Reply.class);
877+
Domain.Reply reply = (Domain.Reply)maybeResponse.get();
876878
}
877879
}
878880
```
@@ -914,11 +916,12 @@ So you could define and call this actor at runtime like this:
914916
```Java
915917
ActorRef mike = spawnSystem.createActorRef("spawn-system", "mike", "abs_actor");
916918

917-
Domain.Request msg = Domain.Request.newBuilder()
918-
.setLanguage("erlang")
919-
.build();
920-
Domain.Reply reply =
921-
(Domain.Reply) mike.invoke("setLanguage", msg, Domain.Reply.class);
919+
Domain.Request msg = Domain.Request.newBuilder()
920+
.setLanguage("erlang")
921+
.build();
922+
923+
Optional<Object> maybeResponse = mike.invoke("setLanguage", msg, Domain.Reply.class);
924+
Domain.Reply reply = (Domain.Reply)maybeResponse.get();
922925
```
923926

924927
The important part of the code above is the following snippet:

0 commit comments

Comments
 (0)