- to gracefully handle actor failures Akka uses Supervision and Monitoring patterns
- Fault Tolerance in Akka
- Note there were significant differences introduced in Akka Typed version regarding error handling. You can read more here
- Akka Location Transparency
- Akka Actor Discovery can be implemented with the receptionist pattern. See Bank.scala for an example.
- Note In Akka Typed, there is no way to contact actors on a different machine with actors' paths (support was dropped as it is usually a bad idea to contact actors directly via the path). You can communicate between machines transparently using Akka Cluster capabilities.
- Cluster settings can be found in application.conf
- For HTTP communication (both server and client) the Akka HTTP library can be used.
- Take a look and try to run HttpServer and then HttpClient
- Server uses high level DSL to compose HTTP route, see
- Client is an actor which makes a request and then pipes the HTTP response to itself
The template for Lab 5: https://github.com/agh-reactive/reactive-scala-labs-templates/tree/lab-5
- be sure that your local lab-5 branch is up to date with remote one
- remember about merging solution from lab-4 into this branch
In the template, ProductCatalog
has been implemented. An example of communication with ProductCatalog
from a different ActorSystem
using the receptionist pattern with cluster setup is implemented in ProductCatalogRemoteTest.scala. Product catalog has several responsibilities:
-
storing
Item
s, in accordance with lab4 convention (id as URI), and with number of items in the warehouse -
searching for items by keywords
- Example of products:
name brand Frappuccino Coffee Drink Starbucks Moisturizing Cream Gerber 32 New Disposable Razor Twin Blades Gillette Coke Classic Bottles Coca-Cola - Query example:
gerber cream
- brand name following the product name. - As a result, 10 best matching results are returned.
- Data is imported from
query_result.bz2
file committed into template resources (data is loaded into memory, soProductCatalog
is memory intensive).
- (15 points) Please create REST API for
ProductCatalog
exposing the search functionality. Results should be returned as JSON. RunProductCatalog
on an actor system different than the HTTP server (to demonstrate remote communication via the receptionist pattern). While implementing Akka HTTP server, please take a look atHelloWorldAkkaHttpServer
example in templates.
- (10 points) Implement the
Payment
actor that communicates with external payments services via HTTP (e.g. VISA, PayU, PayPal) - use thePaymentService
. The payment serverPaymentServiceServer
is implemented for you - please start it before testing. Use a separatePaymentService
actor for each payment request.
- (15 points) Add proper payment error handling. Use strategy supervising for Server transient errors, watch actor for unrecoverable errors and notifying external actors about the payment rejection. See this.