Last active
December 18, 2015 19:16
-
-
Save shelajev/b6b9ac6f9ac34b1facab to your computer and use it in GitHub Desktop.
RebelLabs post: Exploring the virtues of microservices with Play and Akka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| activator new # create a new project | |
| activator run # run the current project | |
| activator shell # open the CLI shell into the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WSRequest complexRequest = request.setHeader("headerKey", "headerValue") | |
| .setRequestTimeout(1000) | |
| .setQueryParameter("paramKey", "paramValue"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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