Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to work with akka from nodejs

I have an application frontend, implemented on angularjs + nodejs + express + socket.io. There's also a feature in a separate service. This service is written on akka.

Here's the way of how the entire communication pipeline may look:

[user enters a value] -> [angularjs gets the value and send it to nodejs server thru socket.io] -> [nodejs receives the value and channel it to akka] -> [akka performs some calculation and return a response] -> [nodejs receive the response and channel it to angularapp].

One possible solution would be to introduce a MQ middleware and use it for the interaction, but such "message driven approach" seems like an overhead for something that clearly looks like an RPC call. What is the best way to build up such type of communication between nodejs and akka?

like image 368
theocat Avatar asked Jun 06 '15 21:06

theocat


People also ask

Is Akka a good framework?

Akka is a truly reactive framework because everything in the sense of sending and receiving a message to Actors, is lock-less, non-blocking IO, and asynchronous.

Is node JS GOOD FOR REST API?

Quick & easy development Node. js has large and active community that contribute many useful and mature modules which can be easily included and used. For example, to construct REST API such known modules as express, restify and hapi fit perfectly.

Can Tomcat run Nodejs?

You can run Nodejs such as react or angular on JavaPipe's Tomcat service. You will need to use npm run build to package the Nodejs for production. It creates a build folder where you can package it as a war file. cd into the build directory and then run jar cvf webui.


2 Answers

Since Akka speaks HTTP itself you can just make a RESTful call from Node to the Akka service. Pipelining is supported so you can make this very efficient. Within the Akka HTTP server flow you use the ask pattern to get the calculated value back from your actor.

like image 94
Roland Kuhn Avatar answered Oct 12 '22 15:10

Roland Kuhn


The cleanest way would to be to skip node.js/socket.io for the messaging layer and instead use websockets over spray.io directly. Typesafe has an activator template for just the scenario of websockets to akka actors: Spray and Websocket interfaces to actors

Otherwise you would be looking at some kind of RPC middleware, maybe Thrift or ZeroMQ.

like image 36
Arne Claassen Avatar answered Oct 12 '22 16:10

Arne Claassen