Skip to content

Instantly share code, notes, and snippets.

@shelajev
Last active December 18, 2015 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shelajev/b6b9ac6f9ac34b1facab to your computer and use it in GitHub Desktop.
Save shelajev/b6b9ac6f9ac34b1facab to your computer and use it in GitHub Desktop.
RebelLabs post: Exploring the virtues of microservices with Play and Akka
activator new # create a new project
activator run # run the current project
activator shell # open the CLI shell into the project
class ExampleActor extends AbstractActor {
// this child will be destroyed and re-created upon restart by default
final ActorRef other = getContext().actorOf(new Props(OtherActor.class), "childName");
public ExampleActor() {
receive(ReceiveBuilder
.match(Request1.class, r ->
other.tell(r.getMsg(), self())
)
.match(Request2.class, r ->
other.tell(r.getMsg(), sender())
)
.match(Request2.class, r ->
pipe(ask(other, r.getMsg(), 500), context().dispatcher()).to(sender())
)
.build());
}
}
WSRequest complexRequest = request.setHeader("headerKey", "headerValue")
                                 .setRequestTimeout(1000)
                                 .setQueryParameter("paramKey", "paramValue");
Promise<JsonNode> jsonPromise = ws.url(url).get().map(response -> {
   return response.asJson();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment