Skip to content

agh-reactive/reactive-lab5

Repository files navigation

Lab 5 - Handling failures, Akka Actor Discovery with Akka Cluster and Akka HTTP

Handling actor errors

  • 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

Sending messages to actors on a different machine

Supporting the HTTP communication with Akka HTTP

  • 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

Assignment

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 Items, 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, so ProductCatalog is memory intensive).
  1. (15 points) Please create REST API for ProductCatalog exposing the search functionality. Results should be returned as JSON. Run ProductCatalog 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 at HelloWorldAkkaHttpServer example in templates.

Product Catalog HTTP Server architecture

  1. (10 points) Implement the Payment actor that communicates with external payments services via HTTP (e.g. VISA, PayU, PayPal) - use the PaymentService. The payment server PaymentServiceServer is implemented for you - please start it before testing. Use a separate PaymentService actor for each payment request.

Payment architecture

  1. (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.

Payment architecture supervision

About

Akka fault tolerance and remoting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published