Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to implement a request/response protocol using akka and scala?

I've been studying about how I could develop a distributed architecture that implements the protocol request/response using the concept of concurrency through actors.

I concluded that the best way to do this is by creating a response system with synchronous handling of Futures/Promises, and soon after the response, leaving an open channel to receive notifications.

Thus an architecture that would work exactly like a inbox message.

It has some problems.

Thus I would have to maintain two endpoints (actors in the two layers)?

The Problem: The view module requests that a particular element is processed. She sends this command to be processed via RemoteActor on the application server. This server should immediately return the promise that it will notify you when the element is processed. After this, the view module will be waiting the notification of completion of processing.

How do you see this problem?

I am using Scala, Akka and Google Guice.

I believe it is a generic problem that everyone can make use of their solutions. Excuse me if I'm hurting the terms of stackoverflow site.

Thanks in advance

like image 561
ricardogobbo Avatar asked Jun 09 '11 18:06

ricardogobbo


People also ask

What is Scala Akka used for?

Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala. Akka Insights is intelligent monitoring and observability purpose built for Akka.

What is Akka protocol?

Interacting with an Actor in Akka is done through an ActorRef[T] where T is the type of messages the actor accepts, also known as the “protocol”. This ensures that only the right kind of messages can be sent to an actor and also that no one else but the Actor itself can access the Actor instance internals.

Does Akka HTTP use Netty?

The Akka HTTP server backend is the default in Play. You can also use the Netty backend if you choose.

Is Akka HTTP a framework?

Akka HTTP is not a framework–not because we don't like frameworks–but to provide maximum flexibility. For example, you might use the Play framework to implement browser-based interactions or Lagom framework for creating microservices, both of them are also based on Akka.


1 Answers

I don't want to distract from any good answers you may get on Akka, because I unfortunately don't know much about Akka and it's distributed actors features, but I'd like to ask if you've considered any alternatives.

It seems that you basically need an asynchronous RPC library. There are two powerful libraries written in Scala that I know of that may satisfy your requirements - http://sna-projects.com/norbert/ and http://twitter.github.com/finagle/. Finagle gives some really powerful combinators for expressing asynchronous computation dependencies and registering listeners on futures. I'm currently maintaining Norbert, which we use at LinkedIn for some of our distributed systems, such as search.

like image 92
Joshua Hartman Avatar answered Nov 05 '22 06:11

Joshua Hartman